On Thu, 2004-11-11 at 15:29, Ing. Branislav Gerzo wrote:
> Hi all,
> 
> anyone knows how looks _good_ ip adress regexp ?

I would skip re-inventing the wheel and use the Net::IP module.

Example:

use strict;
use warnings;

use Net::IP qw(ip_is_ipv4);

# random but valid
my $ip = "209.168.201.93";

# random and invalid
my $bad_ip = "259.1000.345.701";

for my $curr_ip (($ip, $bad_ip)) {
        if (ip_is_ipv4($curr_ip)) {
                print "IP $curr_ip is GOOD\n";
        } else {
                print "$curr_ip is not a valid IP address\n";
        }
}

# output:
# IP 209.168.201.93 is GOOD
# 259.1000.345.701 is not a valid IP address


--Christopher

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to