in reply to Doing the same thing after each statement in a block...?
If the subs all take the same args:
for (qw( foo bar )) { no strict 'refs'; $_->() || die "Command $_ did not return true!\n"; }
If the subs take inconsistent args:
for ( [ foo => \&foo ], [ bar => sub { bar($arg) } ], ) { my ($name, $sub) = @_; $sub->() || die "Command $name did not return true!\n"; }
Those aren't exactly pretty. autodie is probably much better. In future versions, you'll even be able to give it hints as to what is an error or not. (For example, maybe returning zero is an error for foo(), but it isn't for bar()).
It's still new, but it's actively developed and maintained, and it has been made part of core Perl (but it's available independently as well).
|
|---|