If you know $x and $y are both objects, then I much prefer $x == $y over $x eq $y, your FUD not withstanding. If the objects may overload numification and/or stringification, then that changes things; it can make either or both of == / eq inappropriate. In that case, you can use something from overload but I'm not familiar with it.
| [reply] |
| [reply] |
Indeed, overload says:
- overload::StrVal(arg)
-
Gives string value of arg as in absence of stringify overloading. If you are using this to get the address of a reference (useful for checking if two references point to the same thing) then you may be better off using Scalar::Util::refaddr(), which is faster.
| [reply] |
If you know $x and $y are both objects, then I much prefer $x == $y over $x eq $y, your FUD not withstanding.
Sorry for giving the impression of spreading FUD, which has a definitely bad acceptation. Actually it was a fear, an uncertainty and a doubt of mine, as I hope it was clear enough. Now, AIUI from your explanation, both == and eq are equally fine from the technical POV, aren't they?
I must admit I had never thought what the numification of a (blessed) reference could be:
cognac:~ [19:21:09]$ perl -le 'print for map {$_, 0+$_} bless \(my $x)
+,"A"'
A=SCALAR(0x814fe28)
135593512
cognac:~ [19:21:15]$ perl -le 'print 0x814fe28'
135593512
Thank you for stimulating me to meditate and "experiment" about this! | [reply] [d/l] [select] |
...either or both of == / eq inappropriate. In that case, you can use something from overload but I'm not familiar with it.
That would be overload::StrVal(), to be used with eq. Alternatively, Scalar::Util::refaddr() and ==.
Update: All this has been said, as I noticed after posting.
Anno
| [reply] [d/l] [select] |