#!/usr/bin/perl -w use strict; sub dot2int { my $address = pop; my @bytes; while ($address =~ /(\d+)/g) { push @bytes,$1 } return unpack('N',pack('C*',@bytes)); } my $first = dot2int('192.168.1.120'); my $last = dot2int('192.168.1.141'); my @testcases = qw( 192.168.1.130 193.168.1.122 255.0.0.27 192.168.1.127 192.168.1.144 192.168.1.139 ); print "$first to $last = ". ($last-$first)." addresses in range\n"; foreach (@testcases) { print $_; my $int = dot2int($_); if ($int >= $first && $int <= $last) { print " spammer!!!\n"; } else { print " OK.\n" } }