in reply to Best method for failure recovery?

This is a problem i have faced many times, and ended up writting some really odd code to reuse. But, most of the time, i found goto to be a fine solution. There will be people who will down vote this because the "dislike" goto, though i would guess they have never used it, and have only read that it is bad.
But, goto does require a moments thought. What i have done is something like the following (untested):
use Getopt::Long; my $RECOV_STEP = 'FTP_FILE'; my $optre = &GetOptions("-restart=s" => \$RECOV_STEP); if ($optre == 0) { print "Invalid Option Processing\n"; &usage(); } eval { goto $RECOV_STEP; }; if ($@) { die "Invalid Recovery Step '$RECOV_STEP'\n" }; FTP_FILE: { ### get data print "FTP Step Started\n"; }; LOAD_FILE: { ### load database with file print "Load Step Started\n"; }; CLEANUP: { ### archive data print "Cleanup Step Started\n"; }; sub usage { print "$0 -restart <STEP>\n"; }
I have worked with production operation groups for some time now, and have found that they seem to prefer named restart "steps" as opposed to numbers. <minirant>While this may be diffrent where you are, unless you want to be the person up as night on the phone telling them the numbers, i suggest named steps and a good document.</minirant>
my own worst enemy
-- MZSanford