On 3/30/06, Joshua ben Jore <twists@gmail.com> wrote: > On 3/29/06, Jan Dubois <jand@activestate.com> wrote: > > On Wed, 29 Mar 2006, demerphq wrote: > > > On 3/29/06, Yuval Kogman <nothingmuch@woobling.org> wrote: > > > > On Wed, Mar 29, 2006 at 12:46:57 +0200, demerphq wrote: > > > > > > > > > overload::StrVal is a fairly slow procedure. Is there a reason why > > > > > Tie::RefHash doesnt use Scalar::Util::refaddr() instead? Its much > > > > > faster. > > > > > > > > It probably relates to it's availability, which is a non issue in > > > > core perl, right? > > > > > > Sorry I missed this point.... > > > > > > Scalar::Util is in core since 5.8, and is available for 5.6. > > > > Yes, but refaddr() is new in the core Scalar::Util since 5.8.1, not 5.8. > > It'd be easy enough to fail over to overload::StrVal. I added just > such a snippet to Data::Postponed this morning so I could use a fact > function when possible but still work if it wasn't available. > > I checked Scalar::Util and it's Changes documents 1.09 as the first > version with the refaddr function. > > BEGIN { > eval "use Scalar::Util 1.09 qw( refaddr );"; > if ( not defined &refaddr ) { > *refaddr = \ &overload::StrVal; > } > } That should be *refaddr = sub { if (overload::StrVal($_[0])=~/\(([^)]+)\)$/) { return $1 } else { die "...." } } Otherwise youll have a problem with stuff like my $x=[]; my $ra=refaddr($x); is(refaddr(bless $x,')o=o('),$ra); # this will fail And im using such an evil class name to emphasize the point that you need to be pretty anal about parsing the return of StrVal(). Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next