If I'm following correctly, all you need to do is wrap the require call in an eval. If it is successful, the code loaded and can be used. If it's not, I don't think any of the code can have loaded (a more perlgutsy monk will correct me if that's wrong) and you'll get the error in $@. This snippet might help you get started:
perl -le 'eval { require(shift) }; print $@ ? "ERROR: $@" : "Loaded fi +ne!"' /home/path/to/upgrade/files/my_code.conf ERROR: Can't locate /home/path/to/upgrade/files/my_code.conf in @INC ( +@INC contains: /usr/local/lib/perl5/5.10.0/darwin-2level /usr/local/l +ib/perl5/5.10.0 /usr/local/lib/perl5/site_perl/5.10.0/darwin-2level / +usr/local/lib/perl5/site_perl/5.10.0 /usr/local/lib/perl5/site_perl/5 +.8.2 /usr/local/lib/perl5/site_perl .) at -e line 1. perl -lwe 'eval { require(shift) }; print $@ ? "ERROR: $@" : "Loaded f +ine!"' /usr/local/lib/perl5/5.10.0/CGI.pm Loaded fine!
(update: didn't see drench's reply yet when I started mine.)
In reply to Re: question about checking a script for errors from within a perl program
by Your Mother
in thread question about checking a script for errors from within a perl program
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |