Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Match a Range of IP's

by lhoward (Vicar)
on Sep 30, 2004 at 18:22 UTC ( #395442=note: print w/ replies, xml ) Need Help??

in reply to Match a Range of IP's

IMHO, the right way to do this is to convert all the IPs to integers and compare those. Comparing with a RE will work for most common ones, but trying to determine if is betwen and is not well suited for a regular expression.

if((ip2int($iplow)<=ip2int($ip))\ &&(ip2int($ip) <=ip2int($iphigh))){ #... } sub ip2int{ my $ip=shift; my @s=split /\./,$ip return $s[3]+($s[2]+($s[1]+$s[0]*256)*256)*256; }

Comment on Re: Match a Range of IP's
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-11-28 10:36 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls