I've recently found the need to unravel, debug, and refactor old code that breaks almost every rule in the book (think "Perl Worst Practices" ;). This has presented "interesting" challenges, particularly the need to understand the source of symbols spewed into the main namespace from all manner of careless EXPORTs.

One of the things I want to do is have a running trace (in Apache logs, for example) of subroutine calls with their fully-qualified names. I want to do more than print sub names, however. I want to wrap them using Hook::LexWrap to provide general flexibility for inspecting a multitude of conditions surrounding each call (H::L allows you to install pre- and post- wrappers for subs while preserving the expected behavior of caller()).

I looked in the Devel:: namespace and found some modules that do similar things. However, none of them seem to do exactly what I want:

Toward this end, I'm creating a module, Devel::WrapExports, that behaves as explained above. If, for example, I am facing a monster CGI that 'use's twenty libraries, each of which forcefully exports all kinds of symbols, I can simply say 'use Devel::WrapExports' at the top of the CGI and cause each subroutine that has been (perhaps inadvertently) imported into the CGI to be wrapped with default pre- and post-wrappers to trace entry and exit. I can pass my own callbacks to 'use' and they will be installed as wrappers to do all manner of custom tracing, logging, etc.

I'd like to share the module on CPAN, but I wanted to ask first -- there are lots of Devel:: modules that do tracing, so I don't want to commit my own form of namespace pollution by adding a duplicate. Have I overlooked an existing module that provides the functionality I've described, or have I come up with something novel?

Thanks!


In reply to [RFC: Module proposal] Tracing sneaky EXPORTs using wrappers by krazyk

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.