http://www.perlmonks.org?node_id=568128

Ronnie has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks after yesterdays foolish question - well the question wasn't foolish it was the dolt asking!! - I've a slightly more complex poser. I've a list of subroutines that are to run as part of a daily script. If one of them fails we want to automate the re-running of this script without editing it. I've got the mechanism for doing this unfortunately I can't get any of the subroutines to execute! The subroutine names are held in a hash table :-
my %scripts = ( "010" => { sub => "ACC_GET_STEP", step => '010', }, "020" => { sub => "ACC_PUT_STEP", step => '020', }, "030" => { sub => "ACC_GET_STEP", step => '030', }, );

(The above is a cut down version of the hash values as there are also anonymous entries for the parameters required set up at run time). Now I know that part of the problem is being caused because I'm using the strict pragma. I know how to create a reference to a hash table but an entry to a hash within the hash table?
Can't use string ("ACC_PUT_STEP") as a subroutine ref while "strict re +fs" in use at xxrc_test_putstep.pl line 211.
However even if I remove the strict pragma this code still fails.
SCRIPT: for $script (sort keys %scripts) { next SCRIPT if ! defined $scripts{$script} {execute} ; $step = $scripts{$script} {step} ; $sub = $scripts{$script} {sub} ; if ($script == '020') { print "\n\tRunning Step :: $step Sub :: $sub\n" ; $result = system(&$sub($file, $step)) ; if ($result) { print "\n\tFailed!\n" ; } else { print "\n\tSucceeded!\n" ; } } }

I can think of some alternative - long long winded - ways of re-writing this without using a hash table at all but would like my code to be more concise. Any suggestions?