line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Paths::Tree; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
4
|
|
|
|
|
|
|
@EXPORT_OK = qw/tree()/; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require 5.005_62; |
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
30614
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
219
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
0
|
29
|
my ($class , %vals) = @_; |
13
|
1
|
|
|
|
|
2
|
my $self; |
14
|
1
|
|
|
|
|
9
|
bless $self = { |
15
|
|
|
|
|
|
|
tree => $vals{-tree} , |
16
|
|
|
|
|
|
|
origin=> $vals{-origin}, |
17
|
|
|
|
|
|
|
sub => $vals{-sub} , |
18
|
|
|
|
|
|
|
} , $class; |
19
|
1
|
|
|
|
|
4
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub tree { |
25
|
3
|
|
|
3
|
1
|
14
|
my ($self , $father, $level ,%h) = @_; |
26
|
3
|
100
|
|
|
|
14
|
$father = $self->{origin} unless $father; |
27
|
3
|
|
|
|
|
4
|
foreach my $child ( @{$self->{tree}{$father} }) { |
|
3
|
|
|
|
|
9
|
|
28
|
6
|
50
|
|
|
|
15
|
last if $h{$child};$h{$child}=1; |
|
6
|
|
|
|
|
11
|
|
29
|
6
|
|
|
|
|
15
|
$self->{sub}->($child,$level); |
30
|
6
|
100
|
|
|
|
143
|
$self->tree($child, ($level + 1),%h ) if $self->{tree}{$child}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |