I am trying to find a general solution to getting a reference to a method in a module. Assume that we have a Hello.pm module with a single method in it called "hello".
In a calling program, one would write
use Hello;
Hello->hello('Hi There');
The module is defined as:
package Hello;
sub hello {
my $object=shift;
my $greeting=shift;
say "$greeting";
return;
}
1;
How do I get a code reference to my module test of hello? Eventually I want to build a dispatch table and be able to load it with any number of methods located in other modules.
This does not work:
my $code_ref=&{Hello->hello}
and invoke it like this:
$code_ref->('Hi There');
Any ideas? Thanks!