Problems? Is your data what you think it is? | |
PerlMonks |
Establishing a Subroutine Chain of Custodyby Ovid (Cardinal) |
on Jun 20, 2008 at 10:40 UTC ( [id://693121]=perlquestion: print w/replies, xml ) | Need Help?? |
Ovid has asked for the wisdom of the Perl Monks concerning the following question: 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, New address of my CGI Course.
Back to
Seekers of Perl Wisdom
|
|