while ($row = $cursor->fetchrow_arrayref){ print $row->[0],",",$row->[1]; ### If no rows are returned, print EMPTY ### I tried using if (!defined($row->[0])) but that didnt work }