in reply to Re: Help with logic/syntax
in thread Help with logic/syntax
With my code I was able output such as:
$ ./vlan.pl This is element : 0 This is element : 1 This is element : 2 This is element : 3 found a vlan line found an ifconfig line This is element : 4 found a vlan line found an ifconfig line
Using choroba's code I had to change 1 thing, probably because I'm horrible at communicating :) I just commented out what to match on the ifconfig line
} elsif (/^ifconfig/) { $ifconfig++ #for m/\S+/g; }
because here I just want to count the lines themselves until we run out of ifconfig lines, not the number of words on each line like in the vlan example, then compare that with how many vifs we counted.
At first I was getting this:
hostname host97 vlan 72 ifconfig 504 WRONG!!!
But now I get this:
hostname host97 vlan 72 ifconfig 72
Guess I was overcomplicating it by reading it into an array and then trying to iterate an array since I already have the data preformatted (from another script) when I opened the filehandle in this one. That too can be cleaner, but this is functional and that is what matters until we learn more!
Thank you choroba! this gives me other ideas on other little things like this I'm trying to do!
|
|---|