I\'m trying to basically do a search through the database with Perl to tell if there is an item with a certain ID. This search can return no rows, but it can also return one
my $th = $dbh->prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'});
$th->execute();
my $found = 0;
while ($th->fetch())
{
$found = 1;
}
Your query won't return anything if the row doesn't exist, so you can't de-reference the fetch.
Update: you might want to re-write that as
my $found = $th->fetch();