sub first_row { my ($dbh, $query, @args) = @_ my $sth = $dbh->prepare($query); my $rv = $sth->execute(@args); my $first_row = $sth->fetchrow_hashref; return ($rv, $first_row); } my ($success, $first_result) = first_row($dbh, "SELECT ... "); # and if you don't want to actually check success my $second_result = first_row(...);