You want transparent? How about just doing this from a (Unix) command line (after removing all your debugging code):

$ PERLDB_OPTS="f=3 N LineInfo=xxx" perl -d imlate.pl Default die handler restored. hello! goodbye! hello! goodbye! i'm late! i'm late! i'm late!

This will result in the file xxx containing your trace:

$ cat xxx Package imlate.pl. entering main::hello entering main::goodbye exited main::goodbye entering main::goodbye exited main::goodbye exited main::hello entering main::imlate exited main::imlate

By changing the settings of the "f=n" option, you can change the printout (from perldoc perldebguts):

In all cases shown above, the line indentation shows the call tree. If bit 2 of "frame" is set, a line is printed on exit from a subroutine as well. If bit 4 is set, the arguments are printed along with the caller info. If bit 8 is set, the arguments are printed even if they are tied or references. If bit 16 is set, the return value is printed, too.

Without the LineInfo=xxx, the entering/exited messages will end up on stdout (like in yours).


In reply to Re: code review: pretty print sub entry/exit by bikeNomad
in thread code review: pretty print sub entry/exit by particle

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.