Perl shift Function - Tutorialspoint
文章推薦指數: 80 %
This function returns the first value in an array, deleting it and shifting the elements of the array list to the left by one. If ARRAY is not specified, shifts ... Home CodingGround Jobs Whiteboard Tools Business Teachwithus PerlBasics Perl-Home Perl-Introduction Perl-Environment Perl-SyntaxOverview Perl-DataTypes Perl-Variables Perl-Scalars Perl-Arrays Perl-Hashes Perl-IF...ELSE Perl-Loops Perl-Operators Perl-Date&Time Perl-Subroutines Perl-References Perl-Formats Perl-FileI/O Perl-Directories Perl-ErrorHandling Perl-SpecialVariables Perl-CodingStandard Perl-RegularExpressions Perl-SendingEmail PerlAdvanced Perl-SocketProgramming Perl-ObjectOriented Perl-DatabaseAccess Perl-CGIProgramming Perl-Packages&Modules Perl-ProcessManagement Perl-EmbeddedDocumentation Perl-FunctionsReferences PerlUsefulResources Perl-QuestionsandAnswers Perl-QuickGuide Perl-UsefulResources Perl-Discussion SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho PerlshiftFunction Advertisements PreviousPage NextPage PerlOnlineTraining 46Lectures 4.5hours DeviKillada MoreDetail COMPLETEPERLProgramming 11Lectures 1.5hours HarshitSrivastava MoreDetail PerlforBeginners:LearnAtoZofPerlScriptingHands-on 30Lectures 6hours TELCOMAGlobal MoreDetail Description Thisfunctionreturnsthefirstvalueinanarray,deletingitandshiftingtheelementsofthearraylisttotheleftbyone.IfARRAYisnotspecified,shiftsthe@_arraywithinasubroutine,[email protected],exceptvaluesaretakenfromthestartofthearrayinsteadoftheend. Syntax Followingisthesimplesyntaxforthisfunction− shift([ARRAY]) shift ReturnValue Thisfunctionreturnsundefifthearrayisemptyelsereturnsfirstelementinarray. Example Followingistheexamplecodeshowingitsbasicusage− LiveDemo #!/usr/bin/perl @array=(1..5); while($element=shift(@array)){ print("$element-"); } print("TheEnd\n"); Whenabovecodeisexecuted,itproducesthefollowingresult− 1-2-3-4-5-TheEnd perl_function_references.htm PreviousPage PrintPage NextPage Advertisements
延伸文章資訊
- 1defaults to shifting @ARGV : Special Variables - Perl
#!/usr/bin/perl -w use strict; sub version { print "version\n"; } my $option = shift; # defaults ...
- 2perl shift()函數 - 極客書
定義和用法 ... 返回在一個數組中的第一個值,刪除和移位到左邊的元素數組列表一個位置。如果未指定數組ARRAY,轉移@_數組內的子程序,或@ARGV以其他方式。移位彈出本質上是 ...
- 3Command 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...
- 4Perl Display And Pass Command Line Arguments With @argv
Use the $ARGV[n] to display argument. We use the $#ARGV to get total number of passed argument to...
- 5shift in Perl - Perl Maven
The shift function in Perl will remove the first value of the array passed to it and return it. ....