(Philippe 'BooK' Bruhat) via RT wrote:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=65371 >
>
> On Wed, Feb 02, 2011 at 08:13:53AM -0500, Peter Rabbitson via RT wrote:
>> This sort of code is rather prevalent:
>>
>> package Foo;
>> use base 'bar';
>> ....
>>
>> It reports 'bar' being use()d by base.pm which doesn't help with
>> determining that it actually came from Foo.
>>
>> I think this module needs to treat base.pm and parent.pm in a special
>> manner, given how the one and only purpose of these modules is to
>> require other modules (also note that both of them are part of perl core)
>>
>
> Actually, this module is not about showing class hierarchies: it is
> about showing which code did the initial use/require call to load
> each module that ends up in %INC.
Exactly!
Show quoted text>
> For example, consider:
>
> $ perl -d:TraceUse -e 'package Bar;use base "Exporter";'
> Modules used from -e:
> 1. base 2.13, -e line 1 [Bar]
> 2. strict 1.04, base.pm line 3
> 3. vars 1.01, base.pm line 4
> 4. warnings::register 1.01, vars.pm line 7
> 5. warnings 1.06, warnings/register.pm line 24
> 6. Exporter 5.62, base.pm line 90 (eval 1)
>
> versus:
>
> $ perl -d:TraceUse -e 'use Exporter;package Bar;use base "Exporter";'
> Modules used from -e:
> 1. Exporter 5.62, -e line 1 [main]
> 2. base 2.13, -e line 1 [Bar]
> 3. strict 1.04, base.pm line 3
> 4. vars 1.01, base.pm line 4
> 5. warnings::register 1.01, vars.pm line 7
> 6. warnings 1.06, warnings/register.pm line 24
>
> Also, each module loaded will only be reported once, when it was first
> loaded (except for load failures, where every attempt is recorded).
>
Exactly :)
Show quoted text> Going back to your request: at first, I thought I could for example show
> the package from which base|parent was called, but even there, parent
> and base behave differently, and I have to look at different levels in
> the call stack to find the right package.
perl -d:TraceUse -e 'package Foo; use base "File::Spec"; package Bar;use base "Exporter";'
Modules used from -e:
1. base 2.15, -e line 1 [Foo]
2. strict 1.04, base.pm line 3
3. vars 1.01, base.pm line 4
4. warnings::register 1.01, vars.pm line 7
5. warnings 1.09, warnings/register.pm line 24
6. File::Spec 3.3101, base.pm line 91 (eval 2)
7. File::Spec::Unix 3.3, File/Spec.pm line 22
8. Exporter 5.64_01, base.pm line 91 (eval 5)
This is a bad example but if it was broken into files, there'd be no
way to determine who pulled Exporter in.
Show quoted text> Also, what about modules like 'relative' or 'Module::Pluggable', whose
> purpose is also to require other modules?
There is only so much you can do. I was asking for a base/parent
exception specifically because of their ubiquity. For example in
an average DBIx::Class based project you will have twice the
use base X calls, compared to use X
Cheers