with no input perl -ne ‘...’ - run a one liner on every input line perl -pe ‘...’ - same as -ne, AND print each line perl -i files -e ‘...’ - edit files in place Note the quotes. A single quote prevents the shell from grabbing our program Tuesday, November 1, 2011
variable holding current line number Can use to print only even/odd lines: perl -ne ‘print if $. % 2 == 0’ Can use to print only non-blank lines: perl -ne 'print ++$n . " $_" if /./;' Count number of lines in a file perl -ne 'END {print $.}' Tuesday, November 1, 2011
core modules installed with your perl using perldoc perlmodlib Get a list of search paths for modules using perl -e ‘perl -e '$,="\n"; print @INC' Tuesday, November 1, 2011