$ perl -e 'print "Hello World\n"'
$ perl -e 'print "Hello ";' -e 'print "World\n"'
$ perl -MLWP::Simple -e 'print head ""'
$ perl -mLWP::Simple -e 'print head ""'
$ perl -MCGI=:standard -e 'print header'
$ perl -MCGI='header,start_html' -e 'print header, start_html'
$ perl -n -e 'some code' file1
LINE:
while (<>) {
# your code goes here
}
$ perl -n -e 'print "$. - $_"' file
LINE:
while (<>) {
print "$. - $_"
}
LINE:
while (<>) {
# your code goes here
} continue {
print or die "-p destination: $!\n";
}
$ perl -p -e '$_ = "$. - $_"'
$ perl -n -e 'next LINE unless /pattern/; print $_'
$ perl -ne 'END { print $t } @w = /(\w+)/g; $t += @w' file.txt
$ perl -ane 'END {print $x} $x += @F' file.txt
$ perl -F'\W' -ane 'END {print $x} $x += @F' file.txt
$ perl -F':' -ane '$s{$F[6]}++;' \
>; -e 'END { print "$_ : $s{$_}" for keys %s }' /etc/passwd
$ perl -le 'print "Hello World"'
$ perl -pe 'some code' < input.txt > output.txt
$ perl -i -pe 's/\bPHP\b/Perl/g' file.txt
$perl -i.bak -pe 's/\bPHP\b/Perl/g' file.txt