foreach my $line (@configFile) {
next if $line =~ /^\s*$/;
...
####
foreach (@configFile) {
chomp; # careful of last line in file
next if /^\s*$/; # empty line
next if /^\s*#/; # comment line
when (/^\s*ScriptName:\s+\S+\s*$/) {
($tag,$scriptName) = split(); }
when (/^\s*LogFileName:\s+\S+\s*$/) {
($tag,$logFileName) = split(); }
when (/^\s*NumberOfSteps:\s+[0-9]+\s*$/) {
($tag,$numberOfSteps) = split(); }
when (/\s*Restart:\s+\S+\s*$/) {
($tag,$restart) = split(); }
when (/^\s*Step\s+[0-9]:/) {
$stepNum = $_;
$stepNum =~ s/^\s*Step\s+([0-9]+):.*$/$1/;
$command = $_;
$command =~ s/^\s*Step [0-9]:+\s+//;
$step[$stepNum] = $command;
}
default {
print STDERR "Error: unknown config file line:\n";
print STDERR " $_\n";
$error = 1;
}
}
##
##
when (/^\s*(ScriptName:)\s+(\S+)\s*$/) {
$tag= $1;
$scriptName= $2;
}
##
##
when (/^\s*Step\s+(\d):\s*(.*)/) {
$stepNum = $1;
$command = $2;
$step[$stepNum] = $command;
}
##
##
foreach my $command (@step) {
next unless defined $command; # skip unused numbers
my $ret= system ($command);
...
}