Hi all. Nasty little problem in trying to figure out where a subroutine has come from.

Imagine that you have package 'A' which has a sub named 'foo'. It exports that subroutine to 'B'. It's easy enough, once in 'B', to figure out where 'foo' came from. If you get really confused, you can use &Sub::Identify::stash_name to determine the original package the sub was declared in. However, let's say that you're deep down in the guts of package 'G' and you discover that &A::foo is in your namespace, but you don't know how it got there and the twisty little maze of packages makes it hard to figure out.

Is there some way (I can't think of one offhand) of establishing a "chain of custody" for a subroutine so you can figure out how it got into your target package? I'm thinking that maybe coderefs in @INC might help, but I'm stumped (I'll probably fall back to a brute force binary search through packages, but I'd rather not).

Update: Backstory is that a particular package is calling $self->some_method($foo); and it inherits from Class::Accessor. The latter internally calls $self->set( 'some_method', $foo );, but that &set is &Test::Deep::set and I've no idea how it got there.

Cheers,
Ovid

New address of my CGI Course.


In reply to Establishing a Subroutine Chain of Custody by Ovid

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.