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

Re^2: From database to hash table

by Tux (Monsignor)
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-09-19 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (130 votes), past polls