9 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
my %s = (
s241_504 => {
'cat' => 'S',
'edge' => [
{
'idref' => 's241_508',
'label' => 'SB'
},
{
'idref' => 's241_3',
'label' => 'HD'
},
{
'idref' => 's241_503',
'label' => 'OC'
}
]
},
s241_503 => {
'cat' => 'S',
'edge' => [
{
'idref' => 's241_506',
'label' => 'SB'
},
{
'idref' => 's241_6',
'label' => 'HD'
},
{
'idref' => 's241_507',
'label' => 'OA'
},
{
'idref' => 's241_501',
'label' => 'OP'
},
{
'idref' => 's241_502',
'label' => 'MO'
}
]
},
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sub search_idref {
my $haystack = shift;
my $needle = shift;
my @pitchfork = sort keys %$haystack;
my @solutions;
for my $p (@pitchfork) {
push @solutions, $p if grep
{ $_->{'idref'} eq $needle } @{$haystack->{$p}->{'edge'}};
}
return @solutions;
}
print Dumper search_idref( \%s, 's241_506' );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sub search_idref {
my $haystack = shift;
my $needle = shift;
my @pitchfork = sort keys %$haystack;
my @solutions;
for my $p (@pitchfork) {
push @solutions, $p if grep
{ $_->{'idref'} eq $needle } @{$haystack->{$p}->{'edge'}};
}
return @solutions;
}
print Dumper search_idref( \%s, 's241_506' );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use GraphViz;
sub as_graph {
my $haystack = shift;
my @pitchfork = sort keys %$haystack;
my $g = GraphViz->new();
for my $p (@pitchfork) {
$g->add_edge($p, $_->{'idref'}) for @{$haystack->{$p}->{'edge'}};
}
return $g->as_text;
}
print as_graph( \%s );
9 Einträge, 1 Seite |