Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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";
DeepBar Bar DeeperPub Pub DeeperBar DeepPub
 _  _ _  _  
(_|| | |(_|><

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2016-10-27 19:24 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (369 votes). Check out past polls.