summaryrefslogtreecommitdiff
path: root/dist/Data-Dumper/Dumper.pm
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-02-03 23:09:21 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-02-03 23:11:09 -0800
commitde5ef703c7d8db6517e7d56d9c018d3ad03f210e (patch)
tree18b2b7dd939b001704ed7e45766f6af568fd5e93 /dist/Data-Dumper/Dumper.pm
parent2349afb83e6e66ff2f686fcb3e0ec67a51684811 (diff)
downloadperl-de5ef703c7d8db6517e7d56d9c018d3ad03f210e.tar.gz
[perl #58608] Fix DD’s dumping of qr|\/|
By trying to escape / as \/, DD was turning \/ into \\/, producing invalid qr//’s like qr/ \\/ /. You can’t (and don’t need to) escape a / preceded by a backslash. But you have to make sure \\/ gets escaped properly as \\\/. Counting forward from the beginning of the string and ignoring escaped characters is the proper way to do it.
Diffstat (limited to 'dist/Data-Dumper/Dumper.pm')
-rw-r--r--dist/Data-Dumper/Dumper.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/dist/Data-Dumper/Dumper.pm b/dist/Data-Dumper/Dumper.pm
index fcf06ad5d9..06b5eebb49 100644
--- a/dist/Data-Dumper/Dumper.pm
+++ b/dist/Data-Dumper/Dumper.pm
@@ -373,7 +373,7 @@ sub _dump {
} else {
$pat = "$val";
}
- $pat =~ s,/,\\/,g;
+ $pat =~ s <(\\.)|/> { $1 || '\\/' }ge;
$out .= "qr/$pat/";
}
elsif ($realtype eq 'SCALAR' || $realtype eq 'REF'