RESTART: while ( 1 ) { COMMAND: foreach my $CommandHsh (@{$command_section}){ $Result = $self->ExecuteCommand($CommandHsh); $Restart = 0; # set to false if ($Result eq "END"){ $self->{_logfile}->debug("Signal received to END command section"); 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 section"); $Restart = 1; # set to true } else { $self->{_logfile}->error("Incorrect exit type from ExecuteCommand"); } } ### end COMMAND foreach next RESTART if $Restart; ### only get here if NOT restarting - finish up ### $self->{_logfile}->info("End of CommandSection"); last RESTART; }