Perl next Statement
The Perl next statement is used to stop executing the statements from the one after the next statement to the end-of-loop-body marker, switch to executing 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 [ LABEL ];
Here LABEL is optional; if LABEL is not 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
)
{
$a
=
$a
1;
next
;
}
"
The value of a is:
$a
\n
"
;
$a
=
$a
1
;
}
Running the above program, the output is:
a 的值为: 10
a 的值为: 11
a 的值为: 12
a 的值为: 13
a 的值为: 14
a 的值为: 16
a 的值为: 17
a 的值为: 18
a 的值为: 19
Perl Loops