Skip Menu |

This queue is for tickets about the NetAddr-IP CPAN distribution.

Report information
The Basics
Id: 101958
Status: rejected
Priority: 0/
Queue: NetAddr-IP

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

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



Subject: Incorrectly states that two IP addresses are different when they are the same
This program prints No instead of Yes: #!/usr/bin/env perl use NetAddr::IP; my $ip = NetAddr::IP->new('180.020.200.200'); my $ip2 = NetAddr::IP->new('180.20.200.200'); if($ip eq $ip2) { print "Yes\n"; } else { print "No\n"; }
I did wonder if new_no would help, but it doesn't: use NetAddr::IP::Util; use NetAddr::IP; my $ip = NetAddr::IP->new_no('180.020.200.200'); my $ip2 = NetAddr::IP->new_no('180.20.200.200'); if($ip eq $ip2) { print "Yes\n"; } else { print "No\n"; } Prints no, whereas: use NetAddr::IP::Util; use NetAddr::IP; my $ip = NetAddr::IP->new_no('180.020.200.200'); my $ip2 = NetAddr::IP->new_no('180.16.200.200'); if($ip eq $ip2) { print "Yes\n"; } else { print "No\n"; } Prints yes.
Prefacing a number with an "0" (zero) designates it as octal. i.e. 020 = 16 On Thu Feb 05 18:01:09 2015, NHORNE wrote: Show quoted text
> This program prints No instead of Yes: > > #!/usr/bin/env perl > > use NetAddr::IP; > > my $ip = NetAddr::IP->new('180.020.200.200'); > my $ip2 = NetAddr::IP->new('180.20.200.200'); > > if($ip eq $ip2) { > print "Yes\n"; > } else { > print "No\n"; > }
On Fri Feb 06 20:33:14 2015, MIKER wrote: Show quoted text
> Prefacing a number with an "0" (zero) designates it as octal. > i.e. 020 = 16
Why? What RFC is that mentioned in?
On Sat Feb 07 18:40:47 2015, NHORNE wrote: Show quoted text
> On Fri Feb 06 20:33:14 2015, MIKER wrote:
> > Prefacing a number with an "0" (zero) designates it as octal. > > i.e. 020 = 16
> > Why? What RFC is that mentioned in?
It is not an RFC, it is the way base Perl Socket functions work. Socket.pm inet_aton interprets digit strings with leading zeros as octal i.e. use Socket; print inet_ntoa(inet_aton('1.2.020.3')),"\n"; print inet_ntoa(inet_aton('1.2.16.3')),"\n"; produces: 1.2.16.3 1.2.16.3 Sorry if you don't like the way Perl works but that's how it is. It has nothing to do with NetAddr::IP which clones or uses inet_aton where available.
Subject: Re: [rt.cpan.org #101958] Incorrectly states that two IP addresses are different when they are the same
Date: Fri, 25 Mar 2016 18:23:51 -0700
To: bug-NetAddr-IP [...] rt.cpan.org
From: michael [...] insulin-pumpers.org
Should be fixed in latest release. Michael Show quoted text
> Queue: NetAddr-IP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=101958 > > > I did wonder if new_no would help, but it doesn't: > > use NetAddr::IP::Util; > use NetAddr::IP; > my $ip = NetAddr::IP->new_no('180.020.200.200'); > my $ip2 = NetAddr::IP->new_no('180.20.200.200'); > if($ip eq $ip2) { print "Yes\n"; } else { print "No\n"; } > > Prints no, whereas: > > use NetAddr::IP::Util; > use NetAddr::IP; > my $ip = NetAddr::IP->new_no('180.020.200.200'); > my $ip2 = NetAddr::IP->new_no('180.16.200.200'); > if($ip eq $ip2) { print "Yes\n"; } else { print "No\n"; } > > Prints yes.