my $sth = $dbh->prepare(...); $sth->execute(...); my $row = $sth->fetchrow_hashref; unless ($row) { # no rows returned } else { # process $row } $sth->finish;