in reply to code ref
You can also do things like pass in a ref to the class method, and just pass in self.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");
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.$class_method_ref = \&Foo::whee; &$class_method_ref($foo_ob);
$foo_ob->bar("himom"); Foo::bar($foo_ob, "himom"); Foo->bar("himom");
|
---|