#!/usr/bin/perl use warnings; use strict; use DBI; use Data::Dumper; my $db = DBI->connect("dbi:$driver:", q(), q()); my %hash; my $sth = $db->prepare('select week, month, workperiod from tablename'); $sth->execute; while (my ($week, $month, $workperiod) = $sth->fetchrow_array) { $hash{$week} = [$month, $workperiod]; } print Dumper \%hash;