3 # Useful code I didn't feel like duplicating all over the place.
8 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug);
12 $VERSION = 1.00; # set the version for version checking
13 $debug = $ENV{DEBUG} || 0;
15 @EXPORT_OK = qw(&maxwidth &hashdump);
16 %EXPORT_TAGS = ( all
=> [qw(&maxwidth &hashdump)], );
22 return (sort {$a <=> $b} map {length} @_)[-1];
28 if (ref($val) =~ /HASH/) {
29 print "$pre = HASH w/ " . scalar(keys %$val) . " keys.\n";
30 my $w2 = maxwidth
(keys %$val);
31 foreach (sort keys %$val) {
32 &hashdump
($pre . '->{' . sprintf('%' . $w2 .'s', $_) . '}', $val->{$_});
35 } elsif (ref($val) =~ /ARRAY/) {
36 print "$pre = ARRAY w/ " . scalar(@
$val) . " members.\n";
37 my $w2 = maxwidth
(@
$val);
39 &hashdump
($pre . '->{' . sprintf('%' . $w2 .'s', $_) . '}', $_);
43 print "$pre = $val\n";