您的位置:首页 > 其它

perl 的eval中,不应当使用 next

2011-12-08 16:52 176 查看
The next command is like the continue statement in C; it starts the next iteration of the loop:

LINE: while (<STDIN>) {

next LINE if /^#/; # discard comments

#...

}

Note that if there were a continue block on the above, it would get executed even on discarded lines. If the LABEL is omitted, the command refers to the innermost enclosing loop.

next cannot be used to exit a block which returns a value such as eval {} , sub {} or do {} , and should not be used to exit a grep() or map() operation.

Note that a block by itself is semantically identical to a loop that executes once. Thus next will exit such a block early.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: