From: Rick Delaney Date: Wed, 3 Nov 2004 19:46:16 +0000 (-0500) Subject: Re: [PATCH perl-current] Re: [perl #31793] Data::Dumper: Useqq interacts badly with... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1b1d102f0a25a469525d1d8639733ed50d8b39b6;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH perl-current] Re: [perl #31793] Data::Dumper: Useqq interacts badly with overloading Message-ID: <20041104004616.GA11214@biff.bort.ca> p4raw-id: //depot/perl@23470 --- diff --git a/lib/overload.pm b/lib/overload.pm index 237856f..71b550a 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -93,11 +93,7 @@ sub AddrRef { return sprintf("$class_prefix$type(0x%x)", $addr); } -sub StrVal { - (ref $_[0] && OverloadedStringify($_[0]) or ref($_[0]) eq 'Regexp') ? - (AddrRef(shift)) : - "$_[0]"; -} +*StrVal = *AddrRef; sub mycan { # Real can would leave stubs. my ($package, $meth) = @_; diff --git a/lib/overload.t b/lib/overload.t index 173a177..a30a53b 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -1139,9 +1139,12 @@ test ($@ =~ /zap/); { package perl31793; + use overload cmp => sub { 0 }; + package perl31793_fb; use overload cmp => sub { 0 }, fallback => 1; package main; my $o = bless [], 'perl31793'; + my $of = bless [], 'perl31793_fb'; my $no = bless [], 'no_overload'; test (overload::StrVal(\"scalar") =~ /^SCALAR\(0x[0-9a-f]+\)$/); test (overload::StrVal([]) =~ /^ARRAY\(0x[0-9a-f]+\)$/); @@ -1151,6 +1154,7 @@ test ($@ =~ /zap/); test (overload::StrVal(\$o) =~ /^REF\(0x[0-9a-f]+\)$/); test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/); test (overload::StrVal($o) =~ /^perl31793=ARRAY\(0x[0-9a-f]+\)$/); + test (overload::StrVal($of) =~ /^perl31793_fb=ARRAY\(0x[0-9a-f]+\)$/); test (overload::StrVal($no) =~ /^no_overload=ARRAY\(0x[0-9a-f]+\)$/); } @@ -1199,4 +1203,4 @@ foreach my $op (qw(<=> == != < <= > >=)) { # Last test is: -sub last {496} +sub last {497}