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

Answer: How do I reference methods?

by Joost (Canon)
on May 24, 2002 at 16:39 UTC ( #169141=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > How do I reference methods? - Answer contributed by Joost

you can use the UNIVERSAL::can method:

my $object = Ojbect->new; # normal call $object->call(); # get ref my $ref = $object->can('call'); $ref->($object); # use reference..

This will also follow normal inheritance rules.

Note: you probably need to use the object you want to call as the first argument, because normal object methods expect $self to be the first arguments. (that's what $object->call() does anyway)...

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2017-02-24 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (356 votes). Check out past polls.