home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
gnu
/
perl-4.036.tar.gz
/
perl-4.036.tar
/
perl-4.036
/
lib
/
dumpvar.pl
< prev
next >
Wrap
Perl Script
|
1993-02-08
|
820b
|
38 lines
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,@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 = '",&unctrl($entry),"'\n";
}
if (defined @entry) {
print "\@$key = (\n";
foreach $num ($[ .. $#entry) {
print " $num\t'",&unctrl($entry[$num]),"'\n";
}
print ")\n";
}
if ($key ne "_$package" && $key ne "_DB" && defined %entry) {
print "\%$key = (\n";
foreach $key (sort keys(%entry)) {
print " $key\t'",&unctrl($entry{$key}),"'\n";
}
print ")\n";
}
}
}
}
1;