aplonis has asked for the wisdom of the Perl Monks concerning the following question:
I have need of calling any one of umpteen methods, like so...
print join ', ', Module::Submodule::Method( @args );
...where the arg list varies by quantity, etc. The real call is for Device::LabJack with a sample method call like so...
Device::LabJack::AISample( @args );
...and where the method might be 'AISample', 'EAnalogIn', 'EAnalogOut', or any of a long list of others. I don't want to write a separate call for each. What I'd very much like is some means of passing that method name in as a variable...the same variable which I now employ to trigger assembly of an appropriate arg list. Some way of doing what would otherwise look like the (incorrect) usage below...
Device::LabJack::$some_var_name( @args );
Might there be some methodology whereby I can pass a variable to stand in for the method name? I could then use a single outer method to pass that name to the inner like so...
sub pass_thru { my $self = shift; my $method_name = shift; my @args = ...assemble args for $method_name... return Device::Labjack::$_[0](@args)
Thanks,
Gan Uesli Starling
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using $variable in place of "Method" in Module::Submodule::Method( @args )
by Joost (Canon) on Aug 23, 2006 at 19:25 UTC | |
Re: Using $variable in place of "Method" in Module::Submodule::Method( @args )
by izut (Chaplain) on Aug 23, 2006 at 19:25 UTC | |
Re: Using $variable in place of "Method" in Module::Submodule::Method( @args )
by broquaint (Abbot) on Aug 24, 2006 at 14:53 UTC |