Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL last Function



Syntax

last LABEL

last


Definition and Usage

Not a function. The last keyword is a loop-control statement that immediately causes the current iteration of a loop to become the last. No further statements are executed, and the loop ends. If LABEL is specified, then it drops out of the loop identified by LABEL instead of the currently enclosing loop.

Return Value

    Nothing

Example

Try out following example:

#!/usr/bin/perl

$count = 0;

while( 1 ){
   $count = $count + 1;
   if( $count > 4 ){
       print "Going to exist out of the loop\n";
       last;
   }else{
       print "Count is $count\n";
   }
}
print "Out of the loop\n";


It will produce foillowing result:

Count is 1
Count is 2
Count is 3
Count is 4
Going to exist out of the loop
Out of the loop




Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names