Perl next 语句
Perl 教程
· 2019-02-26 22:42:53
Perl next 语句用于停止执行从next语句的下一语句开始到循环体结束标识符之间的语句,转去执行continue语句块,然后再返回到循环体的起始处开始执行下一次循环。
语法
语法格式如下所示:
next [ LABEL ];
其中 LABEL 是可选的,如果没有指定 LABEL,next 语句将返回到循环体的起始处开始执行下一次循环。
实例
#!/usr/bin/perl
$a = 10;
while( $a < 20 ){
if( $a == 15)
{
# 跳出迭代
$a = $a + 1;
next;
}
print "a 的值为: $a\n";
$a = $a + 1;
}
执行以上程序,输出结果为:
a 的值为: 10 a 的值为: 11 a 的值为: 12 a 的值为: 13 a 的值为: 14 a 的值为: 16 a 的值为: 17 a 的值为: 18 a 的值为: 19
点击查看所有 Perl 教程 文章: https://codercto.com/courses/l/19.html
The Four
Scott Galloway / Portfolio / 2017-10-3 / USD 28.00
NEW YORK TIMES BESTSELLER USA TODAY BESTSELLER Amazon, Apple, Facebook, and Google are the four most influential companies on the planet. Just about everyone thinks they know how they got there.......一起来看看 《The Four》 这本书的介绍吧!