Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
Lets say I have a module called Object that has 2 subs (sub1
sub2) that return values (blah1 blah2). In the script that uses
the module I have an array with the modules subroutine names.
I want to go through the array and execute the subroutines in
the object:
use Object;
@subs = qw(sub1 sub2);
$obj = new Object;
for (@subs){
print $obj->$_ . "\n";
}
Of course the above fails. I have tried using eval but must
not be using it correctly. Any info as to what I'm doing
wrong would be greatly appreciated.
Thanks
TG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I access object subs from array?
by merlyn (Sage) on Oct 09, 2001 at 19:24 UTC | |
|
Re: How do I access object subs from array?
by Anonymous Monk on Oct 09, 2001 at 23:57 UTC |