* Part I: File spacing.
* Part II: Line numbering.
* Part III: Calculations (this part).
* Part IV: String creation. Array creation.
* Part V: Text conversion and substitution.
* Part VI: Selective printing and deleting of certain lines.
* Part VII: Release of perl1line.txt.作者: mwm5 时间: 2009-12-28 01:50 标题: Tom Christiansen 先生的列表 # run contents of "my_file" as a program
perl my_file
# run debugger "stand-alone"
perl -d -e 42
# run program, but with warnings
perl -w my_file
# run program under debugger
perl -d my_file
# just check syntax, with warnings
perl -wc my_file
# useful at end of "find foo -print"
perl -nle unlink
# simplest one-liner program
perl -e 'print "hello world!\n"'
# add first and penultimate columns
perl -lane 'print $F[0] + $F[-2]'
# just lines 15 to 17
perl -ne 'print if 15 .. 17' *.pod
# in-place edit of *.c files changing all foo to bar
perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c
# command-line that prints the first 50 lines (cheaply)
perl -pe 'exit if $. > 50' f1 f2 f3 ...