Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

printing complex structures.

by Pug (Monk)
on Jan 25, 2001 at 02:58 UTC ( [id://54147]=CUFP: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://54147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found