Perl

From wikinotes
Revision as of 16:01, 3 March 2018 by Will (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Perl is everywhere. I really need to learn perl.


Perl Interpreter

Perl doesn't use an interpreter quite like python, but there is a debug prompt which lets you use it that way:

perl -de 1								#start interpreter

DB<1> print "hello world"			#example print command
hello world
DB<2>

Multiline Search/Replace

# Replace `Gradient "Nose"` and the 2x lines following it
# with `Gradient "Head"
perl -0777 -pe 's/Gradient "Nose".*\n.*\n.*/Gradient "Head"/g' myfile.txt