Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Understading array of hashes

by kennethk (Abbot)
on Apr 22, 2013 at 19:43 UTC ( #1029966=note: print w/replies, xml ) Need Help??

in reply to Understading array of hashes

warnings gives you a hint with: Useless use of hash element in void context at line 43. In your for loop, you never actually assign anything, so it is a no-op. You get something very close if you uncomment line 41, so you should probably just concentrate on how to modify your output. Essentially, if you don't want to output something, then don't print it:
my %hash; $hash{$_->{'type'}} {$_->{'name'}} = $_->{'reference'} for @$array; #$hash{$_->{'type'}}{ $_->{'name'} }for @$array; print "Results:\n"; for my $k1 (sort keys %hash) { print " $k1:\n"; for my $k2 (sort keys %{$hash{$k1}}) { print " $k2\n"; } }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029966]
[marto]: someone read the post about search.cpan being shut down, and commented "It's going to be awhile before I learn to not type "" into my address bar."
[Discipulus]: ;=) the same here: S + ENTER is my way to cpan in browser
[marto]: doesn't that take you to '', isn't going anywhere, and searches already links to metacpan

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2018-06-20 09:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.