# also brauchst du das hier nicht ;) my $data = {}; while ( my @line = $q->fetchrow_array ) { push @{ $data->{$line[0]} }, $line[1]; } # while