Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Match a Range of IP's

by Zaxo (Archbishop)
on Sep 30, 2004 at 16:21 UTC ( #395398=note: print w/replies, xml ) Need Help??


in reply to Match a Range of IP's

The [1-99] doesn't do what you think. It is a character class which will match a single digit in the range one to nine. That corresponds to what you see.

You can match and test with

while (<DATA>) { print if /^192\.168\.(\d{1,3})\.(\d{1,3})\b/ and $1 > 0 and $1 < 100 and $2 < 256; }
I like to do this kind of thing with IP numbers from Socket::inet_aton(), using bitwise ops, but that isn't such an advantage where netmasks don't correspond to the ranges.

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://395398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2021-01-17 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?