Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by Arunbear (Parson)
on Aug 12, 2011 at 10:26 UTC ( #920010=note: print w/ replies, xml ) Need Help??


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

Store them separately? (And for calling a method, you don't really need a reference)

use strict; sub myMethod { my $self = shift; my ($param) = @_; if ($param) { print "Woohoo, you have successfully passed in a parameter ($p +aram).\n"; } else { print "You have not attempted to pass in a parameter.\n"; } } my ($method, @params) = ('myMethod', 'foo'); my $object = bless {}; $object->$method(@params);
output:
:! perl -w meth.pl Woohoo, you have successfully passed in a parameter (foo).


Comment on Re: how can I store a reference to a method/function along with the parameters?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2015-07-03 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls