描述
这不是功能。 last关键字是一个循环控制语句,该语句立即导致循环的当前迭代变为最后一个。不再执行任何语句,循环结束。如果指定了LABEL,则它将退出LABEL标识的循环,而不是当前封闭的循环。
语法
以下是此函数的简单语法-
last LABEL last
返回值
这不会返回任何值。
例
以下是显示其基本用法的示例代码-
#!/usr/bin/perl
$count = 0;
while( 1 ) {
$count = $count + 1;
if( $count > 4 ) {
print "Going to exist out of the loop\n";
last;
} else {
print "Count is $count\n";
}
}
print "Out of the loop\n";
执行上述代码后,将产生以下输出-
Count is 1 Count is 2 Count is 3 Count is 4 Going to exist out of the loop Out of the loop
Perl 中的 last函数 - 无涯教程网无涯教程网提供描述这不是功能。 last关键字是一个循环控制语句,该语句立即导致循环的当前迭代变为最...
https://www.learnfk.com/perl/perl-last.html


















