my $h; while ( my $row = $sth->fetchrow_arrayref() ) { $h->{$row->[0]} = [ @row[1,2] ]; } # $h will look like { foo => [ 12, blah ], bar => [ .... } # access like $h->{foo}->[0] will give you street no.