-
practical extraction and report language
-
#!usr/bin/perl 是 perl文件解释器的路径
#!usr/bin/perl -w "#"用于单行注释;在后面加-w可以显示程序中出现的一些警告
基础语法
确认安装
perl -v ##通过此命令判断环境下是否已安装perl
执行
perl -c sasa.pl #-c是检查语法,实际没有运行,防止执行后有不可预估的问题
perl sasa.pl #去掉-c就可以执行了
perl -e 'print "hello sasa\n"' #也可以直接在linux命令处写
- 确保文件有可执行权限,在terminal处输入:
chmod 0755 sasa.pl
就不用每次都打这么一长串了;直接在terminal敲文件名回车:
sasa.pl
比如test.pl的内容是:
#!usr/bin/perl
print "hello sasa!\n";
注释
=pod
these comments will be ignored
=cut ### “=”可以用pod进行多行注释 plain old documentations
空格
#!usr/bin/perl
print "hello,sasa\n"; #多个空格,原样输出
#!usr/bin/perl
print "hello
sasa\n"; #会输出多行
hello
空格空格空格sasa