in reply to Referencing a hash of hashes
You can then call the sub like this:my %scripts = ( "010" => { sub => \&ACC_GET_STEP, step => '010', }, "020" => { sub => \&ACC_PUT_STEP, step => '020', }, "030" => { sub => \&ACC_GET_STEP, step => '030', }, );
The first way of doing it looks cleaner and and running subs with a & prefix is a bad habit as it has magic when no arguments are passed.$sub = $scripts{$script}{sub} ; $sub->($file, $step); # Or &$sub($file, $step);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Referencing a hash of hashes
by Ronnie (Scribe) on Aug 18, 2006 at 15:07 UTC | |
by imp (Priest) on Aug 18, 2006 at 15:20 UTC | |
by imp (Priest) on Aug 18, 2006 at 15:35 UTC | |
by chromatic (Archbishop) on Aug 19, 2006 at 01:12 UTC | |
by Ronnie (Scribe) on Aug 21, 2006 at 08:38 UTC |