while() { if (/(\d+)\.(\d+)\.(\d+)\.(\d+)/) { print "$1.$2.$3.$4 "; if ($1<256 and $2<256 and $3<256 and $4<256) { print "is IP\n"; } else { print "is not an IP\n"; } } } __DATA__ 0.0.0.0 255.255.255.255 1.2.3.4 256.1.1.1