duff has a nice clean solution. If you need something more resilient (i.e. cleanup even if the code dies), you can use the following:
use Sub::ScopeFinalizer qw( scope_finalizer ); for my $a (@b) { my $anchor = scope_finalizer { perform_cleanup(); }; next if ...; do_something(); next if ...; do_something_else(); next if ...; do_something_again(); }
In reply to Re: Avoiding goto
by ikegami
in thread Avoiding goto
by elTriberium
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |