in reply to Matching an IP address

Since it hasn't been mentioned:

There's a Net::IPv4Addr module available on CPAN that parses IP addresses and checks legality. It'll also handle addr+netmask pairs like "11.22.33.44/24" or "11.22.33.44/255.255.255.0". The relevant snippet to extract a legal address would be:
use Net::IPv4Addr qw( :all ); if ($ip = ipv4_checkip($str)) { # do something }
Unfortunately, most of the other useful-looking methods croak instead of returning undef on failure, so the documentation says you have eval 'em to handle strings with malformed addresses...