1. With Perl,command-line arguments are stored in the array named @ARGV.
#!/usr/bin/perl
#---------------------#
# PROGRAM: argv.pl #
#---------------------#
$numArgs = $#ARGV + 1;
print "thanks,you gave me $numArgs command-line arguments:/n";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]/n";
}
result :
[root@localhost perl]# ./argv.pl 2 2 2 fd
thanks,you gave me 4 command-line arguments:
2
2
2
fd
2. Scalar variables
$priority = 9;
$priority = 'high';
$priority = '9';
$default = '0009';
[root@localhost perl]# cat basic.pl
#!/usr/bin/perl
#---------------------#
# PROGRAM: basic.pl #
#---------------------#
$a = 'fff';
$b = 'x';
$c = 3;
print '$a and $b';
print "/n";
print "$a and $b";
print "/n";
print $a . $c;
print "/n";
print $a x $c;
print "/n";
result :
[root@localhost perl]# perl basic.pl
$a and $b
fff and x
fff3
fffffffff
3. reg
http://www.comp.leeds.ac.uk/Perl/matching.html
4. subroutine
http://www.comp.leeds.ac.uk/Perl/subroutines.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。