I am looping through a number of queries and when there is an
exception I never want the script to die but to continue looping.
Accordingly, I am using autocheck => 0 in calls like the following line [60]:
$return_value = $mech->field ('ctl00$ctl00$ContentPlaceHolderContent$ContentPlaceHolderMenuAreaLeft$DeviceSearchByCode1$TabDeviceSearchByDeviceCode$TabPanelSearchFilterByDeviceCode$DeviceFilterByDeviceCodeWithNotAct$TbDeviceCode' => '%', autocheck => 0 );
Despite this however, my script fails sporadically with the
following stacktrace;
Uncaught exception from user code:
Can't call method "value" on an undefined value at /usr/share/perl5/WWW/Mechanize.pm line 1403.
at /usr/share/perl5/WWW/Mechanize.pm line 1403
WWW::Mechanize::field('WWW::Mechanize=HASH(0x996abc8)', 'ctl00$ctl00$ContentPlaceHolderContent$ContentPlaceHolderMenuA...', '%', 'autocheck', 0) called at /home/eric/bin/zenatek_login.pl line 60
How may I catch this exception and prevent the script from die-ing?
--
- Eric Smith
autocheck is only meaningful in the constructor. It turns off checks on HTTP requests. It has nothing to do with fields.
> Uncaught exception from user code:
> Can't call method "value" on an undefined value at /usr/share/perl5/WWW/Mechanize.pm line 1403.
> at /usr/share/perl5/WWW/Mechanize.pm line 1403
> WWW::Mechanize::field('WWW::Mechanize=HASH(0x996abc8)', 'ctl00$ctl00$ContentPlaceHolderContent$ContentPlaceHolderMenuA...', '%', 'autocheck', 0) called at /home/eric/bin/zenatek_login.pl line 60
For that, you need to look at the eval function. See perldoc -f veal.
xoa
--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance