my %created = ( AUTHOR => $author,
TYPE => $node_type,
TIME => $node_time,
PARENT => $parent_id || '',
KIDS => [],
);
####
for my $root ( sort { $a <=> $b } keys %created ) {
my $parent = $created{$root}{PARENT};
push @{$created{$parent}{KIDS}}, $root;
}
####
sub print_nodes {
my @kids = @_;
for my $id ( @nodes ) {
print "Interesting data from node\n";
if ( @{$created{$id}{KIDS} ) {
print_nodes( @{$created{$id}{KIDS};
}
}
}
# Some work to make sure we start at the parents and move
# our way down correctly. grep would work just as well.
my @topnodes = ();
for my $id ( keys %created ) {
push @topnodes, $id unless ( defined( $created{$id}{PARENT} ) );
}
print_nodes( @topnodes );