foreach my $a (@b) { if (!...) { do_something(); if (!...) { do_something_else(); if (!...) { do_something_again(); } } } perform_cleanup(); }