Skip Menu |

This queue is for tickets about the Net-Patricia CPAN distribution.

Report information
The Basics
Id: 68311
Status: new
Priority: 0/
Queue: Net-Patricia

People
Owner: Nobody in particular
Requestors: BESSARABV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can't use Net-Patricia for verifying ip address
I want to use Net::Patricia for verifying ip address, but this does not work correctly: {{{ #!/usr/bin/perl use Net::Patricia; use Test::More tests => 3; warn $Net::Patricia::VERSION . "\n"; sub is_ip_address { my ($maybe_ip) = @_; my $pt = new Net::Patricia; $pt->add_string('0.0.0.0/0'); my $result; eval { $result = $pt->match_string($maybe_ip) ? 1 : undef; }; return $result; }; my @good = '127.0.0.1'; my @bad = qw 'test.com 1.2.3'; foreach (@good) { is(is_ip_address($_), 1, "is_ip_address($_)"); } foreach (@bad) { is(is_ip_address($_), undef, "is_ip_address($_)"); } }}} {{{ $ perl bug.t 1..3 1.19 ok 1 - is_ip_address(127.0.0.1) not ok 2 - is_ip_address(test.com) # Failed test 'is_ip_address(test.com)' # at bug.t line 29. # got: '1' # expected: undef not ok 3 - is_ip_address(1.2.3) # Failed test 'is_ip_address(1.2.3)' # at bug.t line 29. # got: '1' # expected: undef # Looks like you failed 2 tests of 3. $ }}}