天天看点

perl与命令行

在linux中运行命令行

perl -e 'print "Hello world\n"'

MS-DOS中运行命令行

perl -e "print qq(Hello world\n)"

直接调用shell并输出

#!/usr/bin/perl -w

my $now=`date`;

print "The time is now $now";

foreach (`who`) {

  my($user,$tty,$date=/(\S+)\s+(\S+)\s+(.*)/;

  $ttys{$user}   .="$tty at $date\n"

}

继续阅读