Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL last Function
Syntax
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
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
|
|

|
|
|