line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UNIVERSAL::derived_classes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
30100
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
126
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub UNIVERSAL::derived_classes { |
9
|
0
|
|
|
0
|
0
|
|
my ($super_class, $reversed) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
if (my $blessed_class = ref $super_class) { |
12
|
0
|
|
|
|
|
|
$super_class = $blessed_class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my @derived_classes; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $find_derived_classes; $find_derived_classes = sub { |
18
|
0
|
|
|
0
|
|
|
my ($outer_class) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $symbol_table_hashref |
21
|
1
|
|
|
1
|
|
6
|
= do { no strict 'refs'; \%{ "${outer_class}::" } }; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
486
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
SYMBOL: |
24
|
0
|
|
|
|
|
|
for my $symbol (keys %$symbol_table_hashref) { |
25
|
0
|
0
|
|
|
|
|
next SYMBOL if $symbol !~ /\A (\w+):: \z/x; |
26
|
0
|
|
|
|
|
|
my $inner_class = $1; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
next SYMBOL if $inner_class eq 'SUPER'; # skip '*::SUPER' |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
my $class = $outer_class ? "${outer_class}::$inner_class" |
31
|
|
|
|
|
|
|
: $inner_class; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
0
|
|
|
|
if ( $class->isa($super_class) and $class ne $super_class ) { |
34
|
0
|
|
|
|
|
|
push @derived_classes, $class; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
next SYMBOL if $class eq 'main'; # skip 'main::*' |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$find_derived_classes->($class); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $root_class = q{}; |
44
|
0
|
|
|
|
|
|
$find_derived_classes->($root_class); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
undef $find_derived_classes; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
@derived_classes = sort { $a->isa($b) ? 1 |
|
0
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
: $b->isa($a) ? -1 |
50
|
|
|
|
|
|
|
: 0 |
51
|
|
|
|
|
|
|
} @derived_classes; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
return reverse @derived_classes if $reversed; |
54
|
0
|
|
|
|
|
|
return @derived_classes ; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub UNIVERSAL::derived_classes_reversed { |
58
|
0
|
|
|
0
|
0
|
|
my ($super_class) = @_; |
59
|
0
|
|
|
|
|
|
return $super_class->derived_classes('reversed'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |