in reply to Using $variable in place of "Method" in Module::Submodule::Method( @args )
Anyway...
# call a method by name. # this works for real methods only. my $method = "some_method"; ClassName->$method(@arguments); $object->$method(@arguments); # or .... # get a subroutine reference and call that # this works provided you call it the right way my $subref = Package->can("some_method"); # call subref as class method Package->$subref(@args); # call subref as object method $object->$subref(@args); # call subref as normal subroutine $subref->(@args);
The last construct is probably what you need.
|
|---|