in reply to Matching an IP address

If I'm not restricted to an regex:
my $ans = 1; my $cnt = 0; for (map {$cnt++ < 4 and $_=~/[0-9]+/ and $_ >= 0 and $_ <= 255 ? 1 : 0} split /\./, $ip) {$ans &= $_};
Not super pretty, nor fast. But TIMTOWDI, as they say.

-Gryn