in reply to Equality operators

Just to confuse matters a bit, because Perl lets me:
#!/usr/bin/perl use strict; no warnings; use Scalar::Util qw/ dualvar /; my $foo = dualvar 1, "foo"; my $bar = dualvar 2, "foo"; print "Using dualvar$/"; print '$foo', ($foo eq $bar ? " eq " : " ne "), '$bar', $/; print '$foo', ($foo == $bar ? " == " : " != "), '$bar', $/; __END__ Using dualvar $foo eq $bar $foo != $bar

Using overload could result in similarly confusing comparisons. This isn't as contrived as it sounds:

#!/usr/bin/perl use strict; use warnings; use URI; my $foo = URI->new('http://www.perlmonks.org'); my $bar = URI->new('http://www.perlmonks.org'); print "Using URI$/"; print '$foo', ($foo eq $bar ? " eq " : " ne "), '$bar', $/; print '$foo', ($foo == $bar ? " == " : " != "), '$bar', $/; __END__ Using URI $foo eq $bar $foo != $bar

URI defines an overload for stringification, but not for numification. In numerical context, objects evaluate to their location in memory. And the two different objects are stored in different locations, so == returns false.

So be careful with == and eq :)