#!/usr/bin/perl
foreach(1..10){
print "Iteration number $_.\n\n";
print "Please choose: last, next, redo, or none of the above?";
chomp(my $choice = <STDIN>);
print "\n";
last if $choice =~ /last/i;
next if $choice =~ /next/i;
redo if $choice =~ /redo/i;
print "That was't any of the choices. onward!\n\n";
}
print "That's all, folks\n"
Perl 的last ,next ,redo 程序控制操作
最新推荐文章于 2019-08-02 20:35:34 发布
本文探讨了使用Perl编程语言实现循环迭代与条件选择的基本概念,通过实例展示了如何使用foreach循环进行迭代,并根据不同条件执行不同的操作,如结束循环、跳过当前迭代或重新执行循环。
371

被折叠的 条评论
为什么被折叠?



