P
Paul Porcelli
I have the following code(excerpt) which grabs some lines from a
syslog
file and adds any found in the range to an array.
@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
foreach (@lines) {
push(@vvlines,$_) if /Volume vol[1-2] verification started/ ..
/Volume vol[1-2] verification ended/;
}
This piece of code is part of a foreach loop which iterates two times.
I have a problem with the following situation:
Pass 1 of the foreach finds the left side of the range but never finds
the right side. This means that the range operator is still true.
Pass 2 of the foreach now pushes all the lines onto the vvlines array
as the range operator is still true. This is not desired. I only want
to push the lines after the left side is matched.
How do I reset the range operator to false between each iteration of
the foreach loop ?
Many thanks.
Paul Porcelli
syslog
file and adds any found in the range to an array.
@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
foreach (@lines) {
push(@vvlines,$_) if /Volume vol[1-2] verification started/ ..
/Volume vol[1-2] verification ended/;
}
This piece of code is part of a foreach loop which iterates two times.
I have a problem with the following situation:
Pass 1 of the foreach finds the left side of the range but never finds
the right side. This means that the range operator is still true.
Pass 2 of the foreach now pushes all the lines onto the vvlines array
as the range operator is still true. This is not desired. I only want
to push the lines after the left side is matched.
How do I reset the range operator to false between each iteration of
the foreach loop ?
Many thanks.
Paul Porcelli