in reply to compare 2 tables of mysql in perl

The error message means that $check is undef, ie probably $dbh->prepare(...) (I hope there's a $ in front) went wrong. Try setting the RaiseError option during DBI->connect to see what went wrong.

See DBI for more information on error handling.