So far I have only used "last" in a block preceded by "for" or "while", but it seems that you can use last in any block with the effect that the remainder of the block is skipped.
So for example this works:
What would you say? Is this an acceptable (even idiomatic use of "last") or just a hack that should be avoided?if($some_condition) { open my $fh, "<", "some_file" or last; # do something with $fh here if the open was successful # if the open fails we skip this part } do_something_else();
In reply to use of last by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |