erabus has asked for the wisdom of the Perl Monks concerning the following question:
sub leaves_under { # read-only method: return a list of all leaves under myself. # Returns myself in the degenerate case of being a leaf myself. my $node = shift; my @List = (); # $node->no_cyclicity; $node->walk_down({ 'callback' => sub { my $node = $_[0]; my @daughters = @{$node->{'daughters'}}; push(@List, $node) unless @daughters; return 1; } }); Carp::croak "Spork Error 861: \@List has no contents!?!?" unless @Li +st; # impossible return @List; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: spork error
by Bloodnok (Vicar) on Apr 10, 2009 at 23:51 UTC | |
|
Re: spork error
by ikegami (Patriarch) on Apr 10, 2009 at 22:43 UTC | |
|
Re: spork error
by erabus (Sexton) on Apr 11, 2009 at 00:06 UTC | |
by ikegami (Patriarch) on Apr 11, 2009 at 03:21 UTC |