die "Bad IP address '$ip'\n" unless $ip && $ip =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/ && !grep { $_ < 0 || $_ > 255 } split(/\./, $ip);
Perhaps not the most elegant solution but readable and tested!
In reply to RE: Matching an IP address
by ncw
in thread Matching an IP address
by bort13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |