Perl continue Statement - Tutorialspoint

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

Perl continue Statement, A continue BLOCK, is always executed just before the conditional is about to be evaluated again. A continue statement can be used ... 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 PerlcontinueStatement Advertisements PreviousPage NextPage  PerlOnlineTraining 46Lectures 4.5hours DeviKillada MoreDetail COMPLETEPERLProgramming 11Lectures 1.5hours HarshitSrivastava MoreDetail PerlforBeginners:LearnAtoZofPerlScriptingHands-on 30Lectures 6hours TELCOMAGlobal MoreDetail AcontinueBLOCK,isalwaysexecutedjustbeforetheconditionalisabouttobeevaluatedagain.Acontinuestatementcanbeusedwithwhileandforeachloops.AcontinuestatementcanalsobeusedalonealongwithaBLOCKofcodeinwhichcaseitwillbeassumedasaflowcontrolstatementratherthanafunction. Syntax Thesyntaxforacontinuestatementwithwhileloopisasfollows− while(condition){ statement(s); }continue{ statement(s); } Thesyntaxforacontinuestatementwithforeachloopisasfollows− foreach$a(@listA){ statement(s); }continue{ statement(s); } ThesyntaxforacontinuestatementwithaBLOCKofcodeisasfollows− continue{ statement(s); } Example Thefollowingprogramsimulatesaforloopusingawhileloop− LiveDemo #/usr/local/bin/perl $a=0; while($a<3){ print"Valueofa=$a\n"; }continue{ $a=$a+1; } Thiswouldproducethefollowingresult− Valueofa=0 Valueofa=1 Valueofa=2 Thefollowingprogramshowstheusageofcontinuestatementwithforeachloop− LiveDemo #/usr/local/bin/perl @list=(1,2,3,4,5); foreach$a(@list){ print"Valueofa=$a\n"; }continue{ lastif$a==4; } Thiswouldproducethefollowingresult− Valueofa=1 Valueofa=2 Valueofa=3 Valueofa=4 perl_loops.htm PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?