Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Database Rows into Perl Hash

by duelafn (Parson)
on Mar 07, 2015 at 12:43 UTC ( [id://1119176]=note: print w/replies, xml ) Need Help??


in reply to Re: Database Rows into Perl Hash
in thread Database Rows into Perl Hash

You could collect the bugs into actual arrays,

while( my( $comp, $bug_num ) = $sth->fetchrow_array() ) { push @{ $hash {$comp} }, $bug_num; }

Whether this is better or wors than constructing a string, of course, depends on how you intend to use the data, though even for producing strings I would generally build the arrays (I hate writing code which builds strings / tests whether the string is non-empty) and join with commas at output time: print join ", ", @{ $hash {$comp} };

Good Day,
    Dean

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1119176]
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: (6)
As of 2024-04-24 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found