Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: From database to hash table

by Tux (Abbot)
on Sep 06, 2012 at 17:26 UTC ( #992155=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    my %hash;
    my %rec;
    while ($sth->fetch) {
        $hash{$rec{week}} = [ $rec{month}, $rec{workperiod} ];
  2. or download this
    my %hash;
    my $sth = $db->prepare ("select week, month, workperiod from tablename
    while ($sth->fetch) {
        $hash{$week} = [ $month, $workperiod ];
  3. or download this
    my $dbh = DBI->connect ("dbi:$driver:", "user", "pass", { FetchHashKey
    +Name => "NAME_lc" });
    my %hash;
    while (my $rec = $sth->fetchrow_hashref) {
        $hash{$rec->{week}} = [ $rec->{month}, $rec->{workperiod} ];

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992155]
[Your Mother]: The good news is, they think they are influencing people but Americans at least are irretrievably biased. All that can be accomplished is a little spike in domestic violence. :P
[LanX]: YM: watch your mouth or I'll show up with my automatic gun at your nursery ...
[LanX]: ;-P
[LanX]: What I learned now is to hide my friends list at FB (not that I have many ...)
[Your Mother]: Careful. They're listening!
[LanX]: I mean hiding my friends FROM my friends

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-03-19 13:29 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.