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

The perl script runs and even prints the message.But it shows error message "The system cannot find the file specified" and the output file is not generated. Why this error occurs. how to solve it.

Replies are listed 'Best First'.
Re: Error log
by Corion (Patriarch) on Nov 24, 2014 at 14:46 UTC

    The error message is not printed by the Perl script. Most likely, you are using system or backticks (qx) to run an external program. That program is not found by your shell and thus, your shell prints The system cannot find the file specified. The most likely cause is that you have spaces in the path to the program you are invoking, and are not properly quoting the path/name of the program you're invoking.

    Usually, checking the return value of system or using autodie would stop your script when it encounters the problem.

Re: Error log
by jellisii2 (Hermit) on Nov 24, 2014 at 16:28 UTC
Re: Error log
by Sathishkumar (Scribe) on Nov 25, 2014 at 07:08 UTC
    The following code helps to capture the error

    The below two line use after module install...

    $SIG{__DIE__} = \&die_handler; my $err_stmt;
    sub die_handler() { $err_stmt = $err_stmt . $_ foreach (@_); $err_stmt =~s/\n/ /igs; open FH,">>Error.txt"; print FH $err_stmt; close FH; }