foreach $id (@id){ $statement = qq{select val1 from tb11 where x=$id}; $col_ref = $dbh->selectcol_arrayref($statement); push @ary,$col_ref; }