I have an idea for a debugging program that might allow me to input a perl script, and it will print out the program substituting the variables with the current (at time of printing) values of each variable. It might also be cool if I set up some sort of trace function where it would actually print out the line of code (line being that seperated by ';') that is currently being utilized...and thus, it might do a couple of lines a couple of times for loops, and it would order sub routines as it needed to. I'm not too worried about writing this script for debugging of other scripts. But I'd like to do this as a subroutine for some of my programs -- so that it will actually do this to itself. My methodology for this is actually reading the perl script and executing the commands after it stores them temporarily into variables. My problem is that I'd be running this on itself, and before I attempt THAT, I think I'd like to make sure that I won't be causing any potential problems. Is there potential problems for a file reading itself to execute itself within itself? I would have a command line sub-command so that I wouldn't end up with a continuous loop.

Is there perhaps a better way to have a script output itself during execution time while also replacing variables with their actual values?

--Coplan


In reply to Ultimate Debugging: by Coplan

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.