Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Array of Hashes

by rjt (Deacon)
on Mar 21, 2013 at 07:50 UTC ( #1024676=note: print w/ replies, xml ) Need Help??


in reply to Array of Hashes

Indeed, Data::Dumper will do. Data::Dump sometimes prints more compact results. Both output formats can be customized to suit your taste, but since this appears to be just debug print you need, the above will probably fit the bill.

You can always roll your own, too, although I'd suggest you think twice or more before you go to a lot of work.

#!/usr/bin/env perl use 5.014; use warnings; use Data::Dump; use Data::Dumper; my @hash_array = map { gen_hash() } 1..10; dd @hash_array; # Dumper(\@hash_array); # Generate a hash ref with some junk in it, two levels deep sub gen_hash { my $h; $h->{int rand 1000}->{int rand 1000} = int rand 1000 for 1..10; return $h; } __END__ Output: ( { 148 => { 570 => 799 }, 279 => { 679 => 288 }, 289 => { 2 => 464 }, 524 => { 501 => 746 }, 527 => { 122 => 839 }, 574 => { 924 => 173 }, 607 => { 295 => 240 }, 662 => { 163 => 277 }, 664 => { 157 => 606 }, 686 => { 32 => 425 }, }, { 232 => { 321 => 314 }, 358 => { 555 => 596 }, 365 => { 116 => 170 }, 579 => { 536 => 659 }, 693 => { 540 => 254 }, . . .


Comment on Re: Array of Hashes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-07-28 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (209 votes), past polls