set_uk has asked for the wisdom of the Perl Monks concerning the following question:
This appears to work but is it the best way:-COMMAND: foreach my $CommandHsh (@{$command_section}){ $Result = $self->ExecuteCommand($CommandHsh); if ($Result eq "END"){ $self->{_logfile}->debug("Signal received to END command secti +on"); last COMMAND; } elsif ($Result eq "CONTINUE"){ $self->{_logfile}->debug("Signal received to CONTINUE command +section"); #next COMMAND; } elsif ($Result eq "RESTART"){ $self->{_logfile}->debug("Signal received to RESTART command s +ection"); redo COMMAND; } else { $self->{_logfile}->error("Incorrect exit type from ExecuteComm +and"); } } $self->{_logfile}->info("End of CommandSection"); }
RESTART: while ( 1 ) { COMMAND: foreach my $CommandHsh (@{$command_section}){ $Result = $self->ExecuteCommand($CommandHsh); if ($Result eq "END"){ $self->{_logfile}->debug("Signal received to END command sec +tion"); last COMMAND; } elsif ($Result eq "CONTINUE"){ $self->{_logfile}->debug("Signal received to CONTINUE comman +d section"); #next COMMAND; } elsif ($Result eq "RESTART"){ $self->{_logfile}->debug("Signal received to RESTART command + section"); next RESTART; } else { $self->{_logfile}->error("Incorrect exit type from ExecuteCo +mmand"); } } $self->{_logfile}->info("End of CommandSection"); last RESTART; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop Control - First?
by hmerrill (Friar) on Oct 28, 2003 at 14:35 UTC | |
|
Re: Loop Control - First?
by simonm (Vicar) on Oct 28, 2003 at 15:35 UTC | |
by Abigail-II (Bishop) on Oct 28, 2003 at 16:39 UTC | |
|
Re: Loop Control - First?
by dragonchild (Archbishop) on Oct 28, 2003 at 15:01 UTC |