Perl last 语句

Perl 教程 · 2019-02-26 22:58:15

Perl last 语句用于退出循环语句块,从而结束循环,last语句之后的语句不再执行,continue语句块也不再执行。

语法

语法格式如下所示:

last [LABEL];

流程图

实例

#!/usr/bin/perl $a = 10; while( $a < 20 ){ if( $a == 15) { # 退出循环 $a = $a + 1; last; } print "a 的值为: $a\n"; $a = $a + 1; }

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

a 的值为: 10
a 的值为: 11
a 的值为: 12
a 的值为: 13
a 的值为: 14

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

查看所有标签

The Master Switch

The Master Switch

Tim Wu / Knopf / 2010-11-2 / USD 27.95

In this age of an open Internet, it is easy to forget that every American information industry, beginning with the telephone, has eventually been taken captive by some ruthless monopoly or cartel. Wit......一起来看看 《The Master Switch》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具