summaryrefslogtreecommitdiff
path: root/lib/dumpvar.pl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dumpvar.pl')
-rw-r--r--lib/dumpvar.pl12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl
index 03dbbcd8fe..4ebcb5203d 100644
--- a/lib/dumpvar.pl
+++ b/lib/dumpvar.pl
@@ -3,18 +3,23 @@ package dumpvar;
# translate control chars to ^X - Randal Schwartz
sub unctrl {
local($_) = @_;
+ return \$_ if ref \$_ eq "GLOB";
s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg;
$_;
}
sub main'dumpvar {
($package,@vars) = @_;
- local(*stab) = *{"::_$package"};
+ $package .= "::" unless $package =~ /::$/;
+ *stab = *{"main::"};
+ while ($package =~ /(\w+?::)/g){
+ *stab = ${stab}{$1};
+ }
while (($key,$val) = each(%stab)) {
{
next if @vars && !grep($key eq $_,@vars);
local(*entry) = $val;
if (defined $entry) {
- print "\$$key = '",&unctrl($entry),"'\n";
+ print "\$",&unctrl($key)," = '",&unctrl($entry),"'\n";
}
if (defined @entry) {
print "\@$key = (\n";
@@ -23,7 +28,8 @@ sub main'dumpvar {
}
print ")\n";
}
- if ($key ne "_$package" && $key ne "_DB" && defined %entry) {
+ if ($key ne "main::" && $key ne "DB::" && defined %entry
+ && !($package eq "dumpvar" and $key eq "stab")) {
print "\%$key = (\n";
foreach $key (sort keys(%entry)) {
print " $key\t'",&unctrl($entry{$key}),"'\n";