in reply to Returning hash reference from a sub
seems to me you are going to a lot of trouble to return a single row.
#sniglet # # somewhere in your while loop return { names => $row->{names} } if $row->{names}; [download]