eastcoastcoder has asked for the wisdom of the Perl Monks concerning the following question:

Hi. When I do:
require 'file.pl' ;

but file.pl doesn't compile, how can I print the error msg? ( || die "$!" doesn't seem to work, don't know why)

Replies are listed 'Best First'.
Re: require error message
by tlm (Prior) on Jun 28, 2005 at 04:35 UTC

    I'd try

    % perl -wc file.pl
    or, if you want more verbose error messages,
    % perl -Mdiagnostics -wc file.pl
    from the command line. This will do a syntax check on file.pl without running it. It should print out the errors and warnings to stderr.

    the lowliest monk

Re: require error message
by BUU (Prior) on Jun 28, 2005 at 05:21 UTC
    eval { require $file } or print $@;