summaryrefslogtreecommitdiff
path: root/lib/dumpvar.pl
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:01:53 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:01:53 +0000
commit154e51a4a1b0258759b5e901183403af515a35b9 (patch)
treede56925bf09e2d98ed44c60b3386d09cd675be3d /lib/dumpvar.pl
parentff8e2863486f651339834bc9e3e0bd49d61ff4e1 (diff)
downloadperl-154e51a4a1b0258759b5e901183403af515a35b9.tar.gz
perl 3.0 patch #22 patch #19, continued
See patch #19.
Diffstat (limited to 'lib/dumpvar.pl')
-rw-r--r--lib/dumpvar.pl15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl
index b8cff8952c..b3fb02b00a 100644
--- a/lib/dumpvar.pl
+++ b/lib/dumpvar.pl
@@ -1,25 +1,32 @@
package dumpvar;
+# translate control chars to ^X - Randal Schwartz
+sub unctrl {
+ local($_) = @_;
+ s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg;
+ $_;
+}
sub main'dumpvar {
- ($package) = @_;
+ ($package,@vars) = @_;
local(*stab) = eval("*_$package");
while (($key,$val) = each(%stab)) {
{
+ next if @vars && !grep($key eq $_,@vars);
local(*entry) = $val;
if (defined $entry) {
- print "\$$key = '$entry'\n";
+ print "\$$key = '",&unctrl($entry),"'\n";
}
if (defined @entry) {
print "\@$key = (\n";
foreach $num ($[ .. $#entry) {
- print " $num\t'",$entry[$num],"'\n";
+ print " $num\t'",&unctrl($entry[$num]),"'\n";
}
print ")\n";
}
if ($key ne "_$package" && defined %entry) {
print "\%$key = (\n";
foreach $key (sort keys(%entry)) {
- print " $key\t'",$entry{$key},"'\n";
+ print " $key\t'",&unctrl($entry{$key}),"'\n";
}
print ")\n";
}