sub leaves { my $node = shift; my @children = $node->children(); if (!@children) { print(join('|', @_), "\n"); } else { for my $child (@children) { leaves($child, @_, $child->value()); } } }