in reply to Re^4: A Scalar::Util::refaddr Oddity
in thread A Scalar::Util::refaddr Oddity
Your code introduces a bug not in the original, here:
overload::StrVal($_[0]) =~ /0x(\w+)/;
You use the same regexp as the original, but because you are no longer blessing into a known package the regexp may match the package name instead of the address. Indeed, a bug common enough to warrant the introduction of a new fatal error in perl-5.8 would give rise to exactly that situation:
zen% cat t0 package A; $x = bless {}; $y = bless [], $x; print "$y"; zen% /opt/perl-5.6.1/bin/perl -wl t0 A=HASH(0x811198c)=ARRAY(0x8111a94) zen% /opt/perl-5.8.0/bin/perl -wl t0 Attempt to bless into a reference at t0 line 1.
Admittedly it is harder to get an overloaded object inadvertently in the wrong class like this, but "0x" is not so unusual a sequence of characters that it is fair to assume it will never appear in a legitimate package name. In any case it is easy enough to fix, with either /.*0x(\w+)/ or /0x(\w+)\)\z/.
Hugo
|
|---|