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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.