in reply to Matching an IP address

Assuming you want to stick to regular expressions, for readability's sake you might want to do this:
$pattern = '[01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]'; /(?:(${pattern})\.){3}($pattern)/; # "$1.$2.$3.$4" = IP if matched
Due the complexity, though, it would probably be tons more efficient to do as other posters suggest and simply loop through the 4 octets:
sub get_octets { my @octets = split(/\./, shift); return unless @octets == 4; foreach (@octets) { $_ += 0; # Perhaps unnecessary, but forces the "octet" to be + numeric or zero return unless $_ >= 0 && $_ <= 255; } return @octets; }