Tuna has asked for the wisdom of the Perl Monks concerning the following question:
In my program, I execute a subroutine N times. This subroutine calls external programs, which return either 0 or 1. I need to keep track of how many times "external.pl" fails. If it fails > 2x, I will enter another sequence of subroutines.
Here's an example:
If I inject an obvious error into the subroutine, such as rename $command to "/bin/lssss", my print statement still prints 0. Any ideas?## In main, I initialize, my $failedActivation = 0; sub activateFirstCluster { my $offlineStatus; if ($failedActivations eq 3 ) { $offlineStatus = &executeTaskSequence($clusterHost, @offLineSequence); } else { $command = "/bin/ls"; ($error = &runSystemCommand($command)) && $failedActivations++; print "failed $failedActivations times\n"; return $success; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Persistent counter
by nehlwyn (Acolyte) on Aug 19, 2001 at 01:16 UTC | |
|
Re: Persistent counter
by Tuna (Friar) on Aug 19, 2001 at 01:19 UTC | |
|
Re: Persistent counter
by little (Curate) on Aug 19, 2001 at 15:17 UTC |