Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Finding classes which are inherited from a given class

by gmax (Abbot)
on Aug 06, 2004 at 10:32 UTC ( #380487=note: print w/ replies, xml ) Need Help??


in reply to Finding classes which are inherited from a given class

There is a tiny module that gives a straight answer. Look for Class::CanBeA

Here is an example of how it works:

#!/usr/bin/perl -w use strict; use Class::CanBeA; package Dummy; sub dummy {}; # not inherited package Foo; sub bar {}; # The ultimate parent package Bar; use base qw(Foo); package DeepBar; use base qw(Bar); package DeeperBar; use base qw(DeepBar); package Pub; use base qw(Foo); package DeepPub; use base qw(Pub); package DeeperPub; use base qw(DeepPub); my @subclasses = @{Class::CanBeA::subclasses('Foo')}; print "@subclasses\n";
output:
DeepBar Bar DeeperPub Pub DeeperBar DeepPub
 _  _ _  _  
(_|| | |(_|><
 _|   


Comment on Re: Finding classes which are inherited from a given class
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://380487]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-10-25 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls