我有一个带有while循环的程序,它有几个点,某些条件需要采取某些操作,然后跳过剩余的迭代.
因为这总是相同的代码,我想把它放在子程序中,但当我尝试使用'next;'时 作为子中的最后一个语句,我得到一个警告(通过下一个退出子程序......),虽然它似乎按预期工作.
即没有子:
while (#condition) {
## do stuff
if (#condition to skip iteration) {
## action
next;
}
## do more stuff, with the above block repeated several times
}
Run Code Online (Sandbox Code Playgroud)
与子:
while (#condition) {
## do stuff
&skip if (#condition to skip iteration);
## do more stuff, with more calls to &skip
}
sub skip() {
## action
next;
}
Run Code Online (Sandbox Code Playgroud)
块/子中的其余代码是如此之短以至于除了下一个之外的所有代码; sub中的语句几乎违背了使用子例程的对象.
我的问题是: