Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

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.


In reply to Automatic trace statements in program by dsangst

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.