in reply to Re: Calling a class method name in a scalar using :: syntax
in thread Calling a class method name in a scalar using :: syntax

If it's a static method then you could do this
my $result = "MODULES::$submodule"->can($method)->($data);
This works because can is returning a reference to the subroutine in MODULES::$submodule and then that it is being called with $data being passed in.

Or, simpler still, if it's a class method then you don't need any trickery

my $result = "MODULES::$submodule"->$method($data);
That just uses the string "MODULES::$submodule" as the class and then calls the method as designated by $method.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Re: Calling a class method name in a scalar using :: syntax
by rufus (Initiate) on Sep 04, 2003 at 15:54 UTC

    Excellent, thank you.

    One of my mistakes was to put the method name between the quotation marks like

    my $result = "MODULES::$submodule->$method($data)"