Perl-Sensitive Sunglasses | |
PerlMonks |
Re: OOP introspection (composition)by LanX (Saint) |
on Apr 02, 2021 at 21:39 UTC ( [id://11130745]=note: print w/replies, xml ) | Need Help?? |
> Also in the case of composition how can I find out which class depends on which class? That's a tougher one, because AFAIK does "classic Perl" only allow imports for "composition". Differing OO-frameworks might have differing approaches and builtin solutions for inspection. But you can iterate over all subs in the namespace° of a class and inspect in which module it was originally defined. There is a core module for that° Sub::Util (read the doc for subname ) ... or something like Sub::Identify from CPAN.
edit°) This won't help you if the composition was done by changing AUTOLOAD , but I don't even know if this approach is even a thing in OOP (?)
Cheers Rolf °) sorry I was wrong about that, Sub::Util is not implementing what Sub::Identify does. But the latter comes with a compact pure Perl implementation using the B backend to extract those informations. AFAICS it's the same approach like described in the book "Perl Hacks".
In Section
Seekers of Perl Wisdom
|
|