Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Pointers to member functions

by japhy (Canon)
on Aug 20, 2001 at 18:55 UTC ( [id://106248]=note: print w/replies, xml ) Need Help??


in reply to Pointers to member functions

What about:
$meth = $obj->can($method_name); $meth->($obj, @args);

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re (tilly) 2: Pointers to member functions
by tilly (Archbishop) on Aug 20, 2001 at 23:29 UTC
    Also note that using a function reference with the method syntax works just fine. Consider the following example where an unnamed method is called from an object in a class with no methods of its own:
    my $foo = bless {}, "bar"; my $meth = sub {shift; print shift}; $foo->$meth("Sneaky");
    (Yeah, I know you know that, but others might find it neat.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-03-19 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found