in reply to checking ip ranges
I think you are testing that the first address is between the second and third. If so then this it the approach I'd use
sub cmp_ips { my $ip = normalize(shift); my $lower = normalize(shift); my $upper = normalize(shift); return 1 if $lower le $ip && $ip le $upper; return 0; } sub normalize { return pack 'C*', split /\./, shift; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: checking ip ranges
by amarquis (Curate) on Mar 13, 2008 at 20:03 UTC |