my $cvterm_id = {} ; # this scalar is a hashref while (my $hashref = $sth->fetchrow_hashref) { $$cvterm_id{$$hashref{termname}} = $$hashref{cvterm_id}; }