-e 开关 --在命令行里直接运行
$perl -e 'print "hello world\n"'
把perl 语句用单引号括起来是为和shell命令区分开
-n 开关 --循环读
$perl -ne 'print;' test.txt
一行一行的打印文件内容
$perl -ne 'print if /^abc/;' test.txt
按行为单位搜索文件以abc开头的行,并打印出来
还可以与管道结合
$date | perl -ne 'print "today is $_";'
还可以重定向
$perl -ne 'print;' <test.txt 读取
$perl -ne 'print ' test.txt > text1.txt
32