- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- 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 - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl last Function
Description
This is 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.
Syntax
Following is the simple syntax for this function −
last LABEL last
Return Value
This does not return any value.
Example
Following is the example code showing its basic usage −
#!/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";
When above code is executed, it produces the following result −
Count is 1 Count is 2 Count is 3 Count is 4 Going to exist out of the loop Out of the loop
perl_function_references.htm
Advertisements