in reply to Re^5: A Scalar::Util::refaddr Oddity
in thread A Scalar::Util::refaddr Oddity
You're the benchmark master. ;-) One-time hit to require overload and then a single function call, or always check blessed, store the original package and bless twice?
Or how about this -- so we only use it if something else has loaded overload and the object is actually overloaded?
sub refaddr_pp { return if not ref $_[0]; if ( exists $INC{'overload.pm'} && overload::Overloaded($_[0]) ) { overload::StrVal($_[0]) =~ /0x(\w+)/; return hex $1; } else { return 0 + $_[0]; } }
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: A Scalar::Util::refaddr Oddity
by adrianh (Chancellor) on Sep 27, 2005 at 13:08 UTC | |
by xdg (Monsignor) on Sep 27, 2005 at 15:43 UTC |