in reply to How do I write subs that take bare blocks as args?
Use a prototype.
Here is an example from Graham Barr's List::Util:
which is invoked assub first (&@) { my $code = shift; foreach (@_) { return $_ if &{$code}(); } undef; }
-Mark# first defined value in @list $foo = first { defined($_) } @list;
|
---|
In Section
Seekers of Perl Wisdom