Perl last Function - Tutorialspoint

文章推薦指數: 80 %
投票人數:10人

Perl last Function, This is not a function. The last keyword is a loop-control statement that immediately causes the current iteration of a loop to become ... 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 PerllastFunction Advertisements PreviousPage NextPage  PerlOnlineTraining 46Lectures 4.5hours DeviKillada MoreDetail COMPLETEPERLProgramming 11Lectures 1.5hours HarshitSrivastava MoreDetail PerlforBeginners:LearnAtoZofPerlScriptingHands-on 30Lectures 6hours TELCOMAGlobal MoreDetail Description Thisisnotafunction.Thelastkeywordisaloop-controlstatementthatimmediatelycausesthecurrentiterationofalooptobecomethelast.Nofurtherstatementsareexecuted,andtheloopends.IfLABELisspecified,thenitdropsoutoftheloopidentifiedbyLABELinsteadofthecurrentlyenclosingloop. Syntax Followingisthesimplesyntaxforthisfunction− lastLABEL last ReturnValue Thisdoesnotreturnanyvalue. Example Followingistheexamplecodeshowingitsbasicusage− LiveDemo #!/usr/bin/perl $count=0; while(1){ $count=$count+1; if($count>4){ print"Goingtoexistoutoftheloop\n"; last; }else{ print"Countis$count\n"; } } print"Outoftheloop\n"; Whenabovecodeisexecuted,itproducesthefollowingresult− Countis1 Countis2 Countis3 Countis4 Goingtoexistoutoftheloop Outoftheloop perl_function_references.htm PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?