Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I write subs that take bare blocks as args?

by kvale (Monsignor)
on Jun 28, 2002 at 06:02 UTC ( #177943=note: print w/ replies, xml ) Need Help??


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:

sub first (&@) { my $code = shift; foreach (@_) { return $_ if &{$code}(); } undef; }
which is invoked as
# first defined value in @list $foo = first { defined($_) } @list;
-Mark


Comment on Re: How do I write subs that take bare blocks as args?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://177943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2014-07-30 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls