YouTip LogoYouTip

Perl Next Statement

# Perl next Statement [![Image 3: Perl Loops](#) Perl Loops](#) The Perl `next` statement is used to stop executing statements from the next statement after `next` until the end of the loop body identifier, and then jump to execute the `continue` block, and then return to the beginning of the loop body to start the next iteration. ### Syntax The syntax format is as follows: next ; Where `LABEL` is optional. If no `LABEL` is specified, the `next` statement will return to the beginning of the loop body to start the next iteration. ## Example #!/usr/bin/perl$a = 10; while($a<20){if($a == 15){# Skip iteration$a = $a + 1; next; }print"a value is: $an"; $a = $a + 1; } Executing the above program, the output result is: a value is: 10 a value is: 11 a value is: 12 a value is: 13 a value is: 14 a value is: 16 a value is: 17 a value is: 18 a value is: 19 [![Image 4: Perl Loops](#) Perl Loops](#)
← Perl Continue StatementPerl Do While Loop β†’