Subject: | incorrect characters escaped in sub backslash |
I think the escaping in sub backslash isn't quite right...
eg
--------------------
use String::Escape qw(backslash);
my $x = q{#$:;<=>?};
print backslash($x)."\n";
--------------------
outputs:
\x23$\x3a\x3b\x3c\x3d\x3e\x3f
whereas presumably it should output:
#\$:;<=>?
A possible patch is just:
--------------------
--- Escape.pm.orig 2012-05-14 19:28:55.739739044 +0100
+++ Escape.pm 2012-05-14 19:45:25.940227607 +0100
@@ -198,7 +198,7 @@
sub backslash ($) {
local $_ = ( defined $_[0] ? $_[0] : '' );
# Preserve only printable ASCII characters other than \, ", $, and @
- s/([^\x20\x21\x24\x25-\x39\x41-\x5b\x5d-\x7e])/\\$Backslashed{$1}/gs;
+ s/([^\x20\x21\x23\x25-\x3f\x41-\x5b\x5d-\x7e])/\\$Backslashed{$1}/gs;
return $_;
}
--------------------
(Btw the perldoc documentation doesn't mention that double quotes should
be escaped by sub backslash, even though the comments do -- I assume the
comments describe the intended behaviour.)
Thanks,
David