|more useful options|
Matching Sequential IP Addressesby Dru (Hermit)
|on Apr 03, 2008 at 18:18 UTC||Need Help??|
Dru has asked for the
wisdom of the Perl Monks concerning the following question:
1.) I have a bunch of ip addresses saved to a hash, with the ip being the hash key. I would like to know those networks (Class C's) that have the last octet in a sequential order from 0.255. For example:
I honestly can not think of an easy way to do this. The only thing I can think of is have 255 if statements and if they all match, I have what I am looking for. I know this is just asinine and I would rather jump off the nearest bridge.
2.) Since I am trying to expand my limited knowledge of map and grep functions, I would be most gratefull if someone could post a solution using either or both of those, which from what I understand of them is probably my best choice.
The closes I can get with grep is the following:
Although this saves the entire ip, rather then the first three octets, which is what I am after. Is it possible to save $1 with grep?
Perl, the Leatherman of Programming languages. - qazwart