YouTip LogoYouTip

Perl Last Statement

# Perl last Statement [![Image 4: Perl Loops](#) Perl Loops](#) The Perl `last` statement is used to exit a loop block, thereby ending the loop. Statements after the `last` statement are not executed, and the `continue` block is also not executed. ### Syntax The syntax format is as follows: last ; ### Flowchart !(#) ## Example #!/usr/bin/perl$a = 10; while($a<20){if($a == 15){# Exit the loop$a = $a + 1; last; }print"The value of a is: $an"; $a = $a + 1; } Executing the above program, the output result is: The value of a is: 10 The value of a is: 11 The value of a is: 12 The value of a is: 13 The value of a is: 14 [![Image 6: Perl Loops](#) Perl Loops](#)
← Bootstrap5 JumbotronBootstrap5 Tables β†’