Sound like you may want to use eval for this, and die instead of next:
foreach (@a) { eval { die 'reason1' if check_condition1(); do_some_stuff(); die 'reason2' if check_condition2(); do_more_stuff(); die 'reason3' if check_condition3(); play_solitaire(); do_something_if_all_ok(); }; # a *real* error, if it doesn't start with 'reason' die if $@ && $@ !~ /^reason/; # save reason; you never know what other evals happen my $reason = $@; # usual continue code here do_something_always(); if($reason) { only_if_reason1() if $@ eq 'reason1' } }
You may want to die with an object of some kind, to easily distinguish between 'real' error, and your type of conditions.
Update: corrected the die regex to Do The Right Thang
In reply to Re: Continue block entry
by Gilimanjaro
in thread Continue block entry
by prowler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |