in reply to Re: How do I write subs that take bare blocks as args?
in thread How do I write subs that take bare blocks as args?
..which also worked. Is there any advantage/disadvantage to this over eval?
The eval version probably isn't doing what you want, unless you are doing something deliciously perverse. I think your original code is doing this:
So you're passing @_ to the user's block, then eval'ing the result. This ends up working because the block presumably accesses $_ directly, and returns an integer (which evals as itself). But it's an ... interesting way to get the job done. An optimist would say that the eval version is "very general".
# "$x = eval &$foo" becomes:
my $tmp = &$foo(@_);
$x = eval $tmp;