Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: code ref

by jackdied (Monk)
on Nov 12, 2002 at 19:45 UTC ( [id://212375]=note: print w/replies, xml ) Need Help??


in reply to code ref

You can do things like pass the name of the func instead of a code ref
package Foo; sub whee { my $self = shift; print "$self says Wheee!\n"; } sub make_whee { my ($instance, $func) = @_; $instance->$func(); } make_whee(Foo->new(), "whee");
You can also do things like pass in a ref to the class method, and just pass in self.
$class_method_ref = \&Foo::whee; &$class_method_ref($foo_ob);
But this will bite you badly later. The ISA tree for Foo will NOT be walked if you call methods in this fashion. Know the diference between these and you are all set.
$foo_ob->bar("himom"); Foo::bar($foo_ob, "himom"); Foo->bar("himom");

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found