in reply to Go to?

On running this script the first thing done - after standard parameter validation - is to see if the stepfile exists. If it does this is a re-run and whatever step number this file contains is where the script re-starts. This is the reason for a goto. I don't think that my program logic is flawed here as the goto is only to be used as part of this automatic re-start code and as such will only be used once.

Hmm ... how about something like a dispatch table keyed by order:

my %cmd_steps = ( 1 => "/bin/ls", 5 => "/bin/uname", 10 => "/bin/dmesg", 15 => "/bin/date", 20 => "/bin/hostname", 25 => "/bin/mount", 30 => "/usr/bin/dir", 35 => "/usr/bin/lpq", 40 => "/bin/ps", ); my $next_step = 15; foreach my $step ( sort { $a <=> $b } keys %cmd_steps ) { next unless $step >= $next_step; print "Step: $step - Cmd: $cmd_steps{ $step }\n"; my $out = `$cmd_steps{$step}`; print $out; print "="x80, "\n"; }

Sure if you have a huge number of steps you'll gain a few cycles using goto vice spinning over unused steps but hey ... tradeoffs.

-derby