my $txt = "169.254.0.210"; if($txt =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.(\d{1,3})/ and ($1 < 250 && $1 > 220)) { print "VALID ADDRESS!\n"; }