Thread Tree::Simple Bug? (9 answers)
Opened by pktm at 2008-09-07 01:27

topeg
 2008-09-07 18:36
#114324 #114324
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Schreib dir doch eine Suchfunktion:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sub find
{
  my $tree = shift;
  my $node_value=shift;
  my $last=0;
  my $child;
  my $func;
  $func = sub ($)
  {
    $child=shift();
    $last=1 if($child->getNodeValue() eq $node_value);
    my @children=$child->getAllChildren();
    $func->(shift(@children)) while(@children && !$last);
  };
  $func->($tree);
  return $child if($last);
  return undef;
}

Aufruf:
Code (perl): (dl )
my $node = find($tree,"<NodeValue>")

View full thread Tree::Simple Bug?