I have been starting to use complex datastructures. This prints out the struct in a (sort of) readable way. Does not deal with circular references.
sub print_hash { my ($temp, $spacer)=@_; my $key; foreach $key (keys(%$temp)) { print "$spacer\ key=$key\tElement=". %$temp->{$key}. " +\n"; if (%$temp->{$key} =~/ARRAY/) { print_array(%$temp->{$key}, $spacer." "); } }print "\n"; } sub print_array { my ($array, $spacer)=@_; my $i; foreach $i (@$array) { print "$spacer\ $i\n"; if ($i =~ /HASH/) { print_hash($i, $spacer." "); } } print "\n"; }

Replies are listed 'Best First'.
Re: printing complex structures.
by myocom (Deacon) on Jan 25, 2001 at 03:00 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.