Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-21 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls