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; }
In reply to Re: checking ip ranges
by hipowls
in thread checking ip ranges
by arcnon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |