develooper Front page | perl.perl5.porters | Postings from February 2012

[perl #58608] Data::Dumper and slashes within qr

Thread Next
From:
Father Chrysostomos via RT
Date:
February 3, 2012 23:43
Subject:
[perl #58608] Data::Dumper and slashes within qr
Message ID:
rt-3.6.HEAD-14510-1328341407-889.58608-15-0@perl.org
On Tue Jan 10 01:08:49 2012, ikegami@adaelis.com wrote:
> On Mon, Jan 9, 2012 at 10:56 PM, Adam Thomason <perlbug-
> followup@perl.org>wrote:
> 
> > The escaping code on line 376 was introduced in 4ab99479, without
> > particular
> > comment to its necessity. Removing it doesn't break DD's test suite,
> but
> > it's quite possible it breaks something else, perhaps an older perl
> which
> > stringifies regexes differently.
> >
> 
> Some escaping of "\" is needed even on latest Perl.
> 
> >perl -MData::Dumper -E"$r=qr(\/); say $r; print Dumper($r);"
> (?^u:\/)
> $VAR1 = qr/(?^u:\\/)/;    # XXX
> 
> >perl -MData::Dumper -E"$r=qr(/); say $r; print Dumper($r);"
> (?^u:/)
> $VAR1 = qr/(?^u:\/)/;    # Ok, but would break if you remove the
> escaping.
> 
> Dumper needs to add "\" in front of "/" unless its preceded by an odd
> number of "\":
> 
> $pat =~ s,/,\\/,g;
> 
> Needs to be something like
> 
> $pat =~ s,(?<!\\)(?:\\\\)*\K/,\\/,g;

I somehow missed this message.  That’s five times the speed of the
pattern I used in de5ef703c.  But unfortunately it won’t work on older
perls.  I doubt it’s worth the complexity of conditionally compiling a
regexp, as the XS version is used mostly.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=58608

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About