Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: easiest way to print the content of a hash?

by davido (Cardinal)
on Jul 13, 2006 at 17:39 UTC ( [id://561020]=note: print w/replies, xml ) Need Help??


in reply to easiest way to print the content of a hash?

If you don't like the output of Data::Dumper and just want a simple key/value dump (without any deep datastructure exploration), you could apply this function:

sub print_hash { my $href = shift; print "$_\t=> $href->{$_}\n" for keys %{$href}; }

It could also be written like this:

sub print_hash { my $href = shift; while( my( $key, $val ) = each %{$href} ) { print "$key\t=>$val\n"; } }

Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found