I think the only piece you are missing is returning the records. you can do this a number or ways. the simplest would be to push() the $ret value onto an array. then return the array at the end of your subroutine. Here is a simple example of how I have done it in the past.
while (@row = $sth->fetchrow) {
if (@row > 1) {
push(@ret,[@row]);
}
else {
push(@ret,@row);
}
}
$sth->finish;
Here I push the entire contents of the fetched rows.