perl的学习 1

perl的学习 1,第1张

概述1. With Perl, command-line arguments are stored in the array named @ARGV. #!/usr/bin/perl #---------------------# #  PROGRAM:  argv.pl  # #---------------------# $numArgs = $#ARGV + 1; print "thanks,

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

总结

以上是内存溢出为你收集整理的perl的学习 1全部内容,希望文章能够帮你解决perl的学习 1所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1288742.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-09
下一篇2022-06-09

发表评论

登录后才能评论

评论列表(0条)

    保存