I am using
do to pull in and excute raw Perl code based on certain criteria. Things were fine, doing the error checking below from the Cookbook.
unless ($return = do $file) {
warn "couldn't parse $file: $@" if $@;
warn "couldn't do $file: $!" unless defined $return;
warn "couldn't run $file" unless $return;
}
Someone else came behind and added code that basically checks for file existence:
if (-e "/path/to/file") {
# do something here;
}
This causes the second error check to fail. I print the error message and get "couldn't do file: No such file or directory". The file being checked for might not always exist. What gives? The file compiles correctly from the command line, yet fails with the
do