sub isValidIP { my $ip = shift; if ( ($a,$b,$c,$d) = $ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) { if (($a|$b|$c|$d) < 256 ) { return 1; } } return 0; }