rgcosma has asked for the wisdom of the Perl Monks concerning the following question:
On execution, it prints "onetwo" while I expected it to run only $hash{1}? What am i doing wrong?perl -e '$choice='1'; %hash=( '0' => &one, '1' => &two ); ${\$hash{$ch +oice}}; sub one {print "one"}; sub two {print "two"}'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: execute function with name passed as string parameter
by Utilitarian (Vicar) on May 05, 2011 at 10:09 UTC | |
|
Re: execute function with name passed as string parameter
by shmem (Chancellor) on May 05, 2011 at 12:05 UTC | |
by rgcosma (Beadle) on May 05, 2011 at 14:30 UTC | |
|
Re: execute function with name passed as string parameter
by chakreey (Acolyte) on May 05, 2011 at 10:45 UTC | |
|
Re: execute function with name passed as string parameter
by NetWallah (Canon) on May 06, 2011 at 05:02 UTC |