dsangst has asked for the wisdom of the Perl Monks concerning the following question:
Hello. I'm a newbie here, and have a problem I haven't been able to solve. Where I work we use Korn shell scripts to process files. The scripts are either kicked off by Cron or by a file being posted. These scripts are quite obscure as a result of trying to "fit" procedural programming into a Korn shell (some of it is quite painful!).
I suggested we rewrite the scripts in Perl and I managed to rewrite one script. The problem is, in the Korn shell scripts we did a "set -x" at the beginning of the script and captured all results to a log file. Whenever something fails we check to log to see why the failure occurred. Is there something similar in Perl that does an automatic trace as the program runs?
I've searched this site (and many others) and most people say "use the debugger", which is fine if you actually run the program. But if something fails when it's kicked off by Cron you can't do that (we can't simulate what happened since we don't know what file was posted, etc).
With the Korn script you can look at the log and say "The if statement said the file was empty. Did you guys send and empty file?". I wondered if there was a "set -x" type debugging option that is NOT interactive for Perl without adding print statements to every line of the program.
The closest thing I found here was this thread:, which of course has the advice "use the debugger", although a couple of functions are listed which could do the job but I couldn't get to work.
Any help here would be appreciated. Thanks.