in reply to error received in WWW::Mechanize

You can use Perl debugger (perl -d myscript.pl, commands t, b, c, n, s) to trace execution of your code and find the cause of this exception.
Sorry, your code example does not allow us to help you further.
Sorry if my advice was wrong.