Skip Menu |

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

Report information
The Basics
Id: 59393
Status: resolved
Priority: 0/
Queue: NetAddr-IP

People
Owner: Nobody in particular
Requestors: simon [...] cocking.id.au
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 4.028
  • 4.029
Fixed in: (no value)



Subject: Overloaded comparison operators don't work as expected
Distribution: NetAddr-IP-4.029 Perl version: This is perl, v5.8.9 built for darwin-2level OS: Darwin 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386 Firstly, while the equality operator 'eq' is overloaded, the operator 'ne' is not, and throws exceptions such as "Can't use string ("127.0.0.1") as a HASH ref while "strict refs" in use at /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level/NetAddr/IP/Lite.pm line 234" because it expects both comparitors to be objects. Secondly, the 'eq' operator does not work as expected: if (NetAddr::IP->new('127.0.0.1') eq '127.0.0.1') { print "yes\n"; } Intuitively, this comparison should match as the IP addresses are identical, but it does not.
See the section in the man page about stringification. Both items in the comparison need to be the same. They can both be objects or both strings, not a mix. i.e. if (NetAddr::IP->new('127.0.0.1')->addr() eq '127.0.0.1') { print "yes\n"; }