I have a nested 'while' loop that won't repeat, no matter how many times the outer loop repeats. The outer loop reads through an array of elements; the inner loop Ithe 'while' loop) is supposed to apply each of these elements while reading an input file.
The outer loop is working fine. It will run through every element of the array. The inner loop, however, only runs once. Even though the outer loop finishes inormally, the inner loop does not repeat.
Here it is:
The outer loop is working fine. It will run through every element of the array. The inner loop, however, only runs once. Even though the outer loop finishes inormally, the inner loop does not repeat.
Here it is:
Code:
foreach $hour (@hourRange) {
$timeBlock = $timeDateBase . $hour;
print "$timeBlock\n";
while (<LOG>) {
chomp;
if ($_ =~ /$timeBlock/) {
print "$timeBlock\n";
($a,$b,$c) = split(/"/, $_);
if ($a =~ /^(\S+)\s-\s-\s\[(\S+)\s/) {
$IP = $1;
$timeString = $2;
print "$IP\n";
print "$timeString\n";
}
}
}
}
Comment