carcassonne has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to be able to call a package method by using variables, one of them being a hash member, like the following. The ProjectA module contains the prepare() function:
use ProjectA; my $project = 'ProjectA'; my %ThingsToDo = (firstTask => 'prepare');
This yields a compilation error:
$project->$ThingsToDo{firstTask}();
Whereas this works allright:
my $temp = $ThingsToDo{firstTask}; $project->$temp();
Is it possible to call the function in the module in this manner without using the $temp variable ?
Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Calling a hash member
by ikegami (Patriarch) on Dec 13, 2006 at 21:08 UTC | |
Re: Calling a hash member
by geekphilosopher (Friar) on Dec 13, 2006 at 21:22 UTC | |
by ikegami (Patriarch) on Dec 13, 2006 at 21:27 UTC | |
by geekphilosopher (Friar) on Dec 14, 2006 at 01:46 UTC | |
by ikegami (Patriarch) on Dec 14, 2006 at 02:06 UTC | |
by geekphilosopher (Friar) on Dec 14, 2006 at 02:42 UTC | |
| |
by revdiablo (Prior) on Dec 13, 2006 at 22:01 UTC | |
Re: Calling a hash member
by leocharre (Priest) on Dec 14, 2006 at 04:54 UTC | |
Re: Calling a hash member
by Devanchya (Beadle) on Dec 13, 2006 at 22:25 UTC | |
Re: Calling a hash member
by ysth (Canon) on Dec 13, 2006 at 22:17 UTC |