Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 imbibing at the Monastery: (4)
As of 2014-12-28 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls