in reply to Iterating and pattern matching on input file
Take a look at what the code in your while loop would do for each line of code:
So it looks like you're expecting 'next' to mean "read the next line" instead of "ignore the rest of the loop".
I expect you probably want something like:
while (my $line = <INPUT>) { my item = "UNKNOWN"; if ($line =~ /show port/) { $item = "port"; } if ($line =~ /show router interface/) { $item = "l3"; } if ($line =~ /Count:\s+(\d+)/) { $checks{$item}{$stage} = $1; } }
Update: Pressed "create" just a bit too soon!
Update: As AnomalousMonk mentions, it's not adding the count value.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Iterating and pattern matching on input file
by AnomalousMonk (Archbishop) on Jul 31, 2018 at 20:50 UTC | |
|
Re^2: Iterating and pattern matching on input file
by bartrad (Beadle) on Jul 31, 2018 at 20:41 UTC | |
by roboticus (Chancellor) on Jul 31, 2018 at 23:50 UTC | |
by AnomalousMonk (Archbishop) on Jul 31, 2018 at 23:57 UTC |