1 system
perl也可以用system调用shell的命令,它和awk的system一样,返回值也是它调用的命令的退出状态.如果向system传递一个字符串作参数,则perl会调用shell来执行这个命令,在这个字符串内也就不可以有perl 的变量了;如果传递多个字符串作参数,则perl会自己执行这个命令,且可以传递perl自己的变量给它,因为perl会对这些变量扩展成它们的值
$ perl
$now = `date`;
print $now;
Sun Mar 8 23:08:24 2009
3 exec
最后,perl还可以使用exec来调用shell的命令. exec和system差不多,不同之处在于,调用exec之后,perl马上就退出,而不会去继续执行剩下的代码
$ perl
exec("date");
print "this line will never be seen.";
Sun Mar 8 23:16:54 2009