Create a sub LC_ALL with the correct prototype.
[p5sagit/p5-mst-13.2.git] / lib / dumpvar.pl
index 474818a..43e107f 100644 (file)
@@ -80,7 +80,7 @@ sub stringify {
        } elsif ($unctrl eq 'quote') {
          s/([\"\\\$\@])/\\$1/g if $tick eq '"';
          s/\033/\\e/g;
-         s/([\000-\037\177])/'\\c'.chr(ord($1)^64)/eg;
+         s/([\000-\037\177])/'\\c'._escaped_ord($1)/eg;
        }
        $_ = uniescape($_);
        s/([\200-\377])/'\\'.sprintf('%3o',ord($1))/eg if $quoteHighBit;
@@ -89,6 +89,14 @@ sub stringify {
          : $tick . $_ . $tick;
 }
 
+# Ensure a resulting \ is escaped to be \\
+sub _escaped_ord {
+    my $chr = shift;
+    $chr = chr(ord($chr)^64);
+    $chr =~ s{\\}{\\\\}g;
+    return $chr;
+}
+
 sub ShortArray {
   my $tArrayDepth = $#{$_[0]} ; 
   $tArrayDepth = $#{$_[0]} < $arrayDepth-1 ? $#{$_[0]} : $arrayDepth-1