Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Match a Range of IP's

by Zaxo (Archbishop)
on Sep 30, 2004 at 16:21 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://395398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found