Using "perl -d" on the script shouldn't be a problem, and there's every good reason to use it as a first resort, so long as you establish some good places to put breakpoints before you start execution. Let me embellish Ovid's advice a bit; if you're on a system with an "egrep" command, just do:
egrep -n 'eval|format' your_script.pl
or if you don't have egrep (well, get it -- the gnu version is available for MS Windows), you could use a command-line perl script to the same effect:
perl -ne 'print "$. $_" if (/eval|format/)' your_script.pl
Anyplace where "format" follows closely after "eval", use the line number of the "eval" to set a breakpoint in the debugger (using the "b" command).

When using the debugger, I find it helpful to have the script also loaded in a text editor that allows going to specific line numbers easily.

If this is a cgi script, you'll either need to set $ENV{QUERY_STRING} to some suitable value before starting execution, or else you may want to "enhance" the script a bit so it can get the query_string args from ARGV if $ENV{QUERY_STRING} happens to be empty. UPDATEHaving just seen that you have multiple source files to work through, exend the egrep to all source files, and also find the names of subs or objects in the "main" script that reference the other sources, and put breakpoints on those names, so that when you "step" into those calls, you can then set line-number based breakpoints within those other source files. Okay, so there's more prep work before actually starting execution in the debugger, but it's still likely to be the shortest path.


In reply to Re: Debugging Perl Program by graff
in thread Debugging Perl Program by pjbrenner

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.