带标号修饰符LABEL的redo语句表示把循环控制流程直接转到与标号修饰符LABEL相关联的语句块的第一行处开始执行,而不再执行redo语句之后的语句和continue语句块; 不带标号修饰符LABEL的redo语句表示把循环控制流程直接转到当前语句块的第一行处开始执行,而不再执行redo语句之后的语句和continue语句块; 如果是在
for 循环 foreach 循环 特殊形式 each do...while 循环 循环控制语句 next 语句 last 语句 continue 语句 redo 语句 goto 语句 特殊变量: 引用 直接引用hard reference 符号引用(软引用) 箭头运算符 匿名数组、hash表和子程序 创建直接引用 引用和自动生成 按引用传递 创建匿名数组的...
退出循环为last,与C中的break作用相同;执行下一个循环为next,与C中的continue作用相同;PERL特有的一个命令是redo,其含义是重复此次循环,即循环变量不变,回到循环起始点,但要注意,redo命令在do循环中不起作用。
continue 语句可用在 while 和 foreach 循环中。 redo [LABEL] 1. 其中LABEL 是可选的。 带标号修饰符LABEL的redo语句表示把循环控制流程直接转到与标号修饰符LABEL相关联的语句块的第一行处开始执行,而不再执行redo语句之后的语句和continue语句块; 不带标号修饰符LABEL的redo语句表示把循环控制流程直接转到当前语句...
foreach $temp (@list) { if ($temp == 2) { $temp = 20; } } 此时@list已变成了(1, 20, 3, 4, 5)。 5、do循环 do { statement_block } while_or_until (condexpr); do循环至少执行一次循环。 6、循环控制 退出循环为last,与C中的break作用相同;执行下一个循环为next,与C中的continue作用...
问Perl编程: continue块EN(1). 简单分类 &...
#!/usr/local/bin/perl for( ; ; ) { printf "This loop will run forever.\n"; } 12345 您可以按Ctrl + C键终止上述无限循环。 当条件表达式不存在时,假定为真。 您可能有一个初始化和增量表达式,但作为程序员,更常见的是使用for(;;)构造来表示无限循环。 Perl - Operators ...
For Loops Perl's C-style "for" loop works like the corresponding "while" loop; that means that this: for ($i = 1; $i < 10; $i++) { ... } is the same as this: $i = 1; while ($i < 10) { ... } continue { $i++; } There is one minor difference: if variables are...
Translated to English, the while condition says to continue so long as the input argument string is not null. You might think that this loop would continue to print the first argument $ARGV[0] forever and ever, since you don't expect the value of the @ARGV variable (the list of ...
foreach$number (0..5) { say"Starting $number";lastif$number>3; say"\$number is $number"; say"Ending $number"; } say'Past the loop'; You start the block for element3but end the loop there and continue the program after the loop: ...