defaults to shifting @ARGV : Special Variables - Perl
文章推薦指數: 80 %
#!/usr/bin/perl -w use strict; sub version { print "version\n"; } my $option = shift; # defaults to shifting @ARGV version() if $option eq "-v" or $option ...
HomePerlArrayCGIClassDataTypeDatabaseFileGUIHashLanguageBasicsNetworkRegularExpressionReportStatementStringSubroutineSystemFunctionsWin32XMLshift:defaultstoshifting@ARGV:SpecialVariables « LanguageBasics « PerlPerlLanguageBasicsSpecialVariablesshift:defaultstoshifting@ARGV
#!/usr/bin/perl-w
usestrict;
subversion{
print"version\n";
}
my$option=shift;#defaultstoshifting@ARGV
version()if$optioneq"-v"or$optioneq"--version";
print"Hello,world.\n";
Relatedexamplesinthesamecategory1.SpecialLiterals2.Splittingup$_3.Splittingup$_andcreatinganunnamedlist4.Thelistseparatorisacomma5.Thelistseparatoristheemptystring6.PassingArgumentsattheCommandLine7.SpecialHashes:The%ENVHash8.The%SIGhashsetssignalhandlersforsignals.9.Aprogramthatchangesthevalueof$/.10.Aprogramthatusesthe$"(dollarandquotation)variable.11.Aprogramthatusesthe$(dollar),variable.12.Aprogramthatusesthe$
延伸文章資訊
- 1perl_how.txt
底下利用一些例子,逐步介紹Perl 的使用從變數的定義到流程、迴圈的控制. ... @ARGV 是全部的參數@ARGV[0] 是第一個參數, @ARGV[1] 是第二個參數print "\@AR...
- 2shift in Perl - Perl Maven
The shift function in Perl will remove the first value of the array passed to it and return it. ....
- 3Processing command line arguments - @ARGV in Perl
In Perl @ARGV contains the raw command line arguments as passed by the user ... You can also use ...
- 4perl shift()函數 - 極客書
定義和用法 ... 返回在一個數組中的第一個值,刪除和移位到左邊的元素數組列表一個位置。如果未指定數組ARRAY,轉移@_數組內的子程序,或@ARGV以其他方式。移位彈出本質上是 ...
- 5Command line argument variable @ARGV in Perl
It chops off the first two arguments from @ARGV and puts them in $var1 and $var2. Personally I wo...