Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: how can I store a reference to a method/function along with the parameters?

by cdarke (Prior)
on Aug 12, 2011 at 08:38 UTC ( [id://919998]=note: print w/replies, xml ) Need Help??


in reply to how can I store a reference to a method/function along with the parameters?

Or you could use a closure:
sub myMethod { my ($param) = @_; return sub { if ($param) { print "Woohoo, you have successfully passed in a parameter + ($param).\n"; } else { print "You have not attempted to pass in a parameter.\n"; } } } my $methodWithoutParam = myMethod(); $methodWithoutParam->(); my $methodWithParam = myMethod('My Param'); $methodWithParam->();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found