Returning a dataset with arrays

Hi! I am a newbie using Perl and I have a big problem , for me, and it is that I need to return a query result into a array but I cant do that. I did this code: sub getcodigodb() { local($table)= shift; local($field)= shift; my $code=shift; my $dbh = open_connection(); my $sql = "SELECT * FROM $table WHERE $field=$code ";