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

Answer: How do I reference methods?

( #169141=categorized answer: print w/ replies, xml ) Need Help??

Q&A > object-oriented programming > How do I reference methods? 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)...

Comment on Answer: How do I reference methods?
Download Code
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2015-11-30 14:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (771 votes), past polls