I strongly disagree.
sub is_same_ref_str { $_[0] eq $_[1] } sub is_same_ref_num { $_[0] == $_[1] } $_ = \$_; print +( "not ", "" )[ is_same_ref_str( $_, "$_" ) ], "the same refere +nce\n"; print +( "not ", "" )[ is_same_ref_num( $_, "$_" ) ], "the same refere +nce\n"; __END__ the same reference not the same reference
I use strict because I like not having to worry about stringified references. I compare them with == for the same reason; that protection is arguably weaker, but it’s still better than using eq.
Of course, if you want to be really conscientous, you need to lug Scalar::Util into every script.
Perl should have had eqref and neref operators to compare with reference semantics, the same way it has eq and ne to compare with string semantics vs == and != to compare with numeric semantics.
Makeshifts last the longest.
In reply to Re^2: The trap of reference numification
by Aristotle
in thread The trap of reference numification
by samtregar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |