Perl continue 语句

Perl 教程 · 2019-02-26 23:12:13

Perl continue 块通常在条件语句再次判断前执行。

continue 语句可用在 while 和 foreach 循环中。

语法

while 循环中 continue 语句语法格式如下所示:

while(condition){
   statement(s);
}continue{
   statement(s);
}

foreach 循环中 continue 语句语法格式如下所示:

foreach $a (@listA){
   statement(s);
}continue{
   statement(s);
}

实例

while 循环中使用 continue 语句:

实例

#/usr/bin/perl $a = 0; while($a < 3){ print "a = $a\n"; }continue{ $a = $a + 1; }

执行以上程序,输出结果为:

a = 0
a = 1
a = 2

foreach 循环中使用 continue 语句:

实例

#/usr/bin/perl @list = (1, 2, 3, 4, 5); foreach $a (@list){ print "a = $a\n"; }continue{ last if $a == 4; }

执行以上程序,输出结果为:

a = 1
a = 2
a = 3
a = 4

点击查看所有 Perl 教程 文章: https://www.codercto.com/courses/l/19.html

查看所有标签

jQuery in Action

jQuery in Action

Bear Bibeault、Yehuda Katz / Manning Publications / 2008-2-17 / USD 39.99

A good web development framework anticipates what you need to do and makes those tasks easier and more efficient; jQuery practically reads your mind. Developers of every stripe-hobbyists and professio......一起来看看 《jQuery in Action》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码