I want a subroutine to call another subroutine, and if the return value from that subroutine is true, this subroutine should return that value, otherwise continue.
I'd think that keeping value retrieval and flow of control separate will be easiest on whoever picks up the code next. That speaks for either of your last two solutions, or something more explicit, like
my $v = thatroutine(); return $v if $v;
Since you're willing to consider taking on the overhead of eval, I rather suspect a temporary variable won't faze you, especially since it offers a convenient debug point for anyone who is stepping through the code.
In reply to Re: looking for a good idiom: return this if this is true
by dws
in thread looking for a good idiom: return this if this is true
by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |