Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Need to get hash of arrays

by 1nickt (Abbot)
on May 14, 2021 at 09:59 UTC ( #11132573=note: print w/replies, xml ) Need Help??


in reply to Need to get hash of arrays

Hi,

By the pipe separator it looks like you are retrieving the data from a MySQL or other database. Is that the case? If so you can populate your hash of arrays while you are fetching the results from the DB.

while ( my $row = $sth->fetchrow_arrayref ) { push( @{ $hash{$row->[0]} }, $row->[1] ); }

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2021-10-28 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (96 votes). Check out past polls.

    Notices?