# Supports ranges in any number of bytes. sub parse_ip_mask { my ($ip_mask) = @_; my @checks; foreach (split(/\./, $ip_mask)) { if (/\[(\d+)-(\d+)\]/) { push(@checks, [ 0+$1, 0+$2 ]); } else { push(@checks, [ 0+$_, 0+$_ ]); } } return \@checks; } sub ip_check { my ($ip, $checks) = @_; my @ip = split(/\./, $ip); my $i; for ($i=0; $i<4; $i++) { return undef if ($ip[$i] < $checks->[$i][0]); return undef if ($ip[$i] > $checks->[$i][1]); } return 1; }