./argv.pl hello perl world
our executable file name is ./argv.pl
arg1 is hello
arg2 is perl
arg3 is world
钻石操作符 <> |
#!/usr/bin/perl
@ARGV = qw/ temp.txt temp2.txt /;
$i = 1;
foreach (@ARGV) {
print "arg$i is $_ \n";
$i++;
}
while (<>) {
chomp;
print "It was \"$_\" \n";
}
./argv.pl hello world
arg1 is temp.txt
arg2 is temp2.txt
It was "hello world"
It was "hello perl"
It was "welcome"
It was "www.groad.net"
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |