in reply to So you think you're good with structures?
my @tables_seen; sub traverse_nodes { my ($db, $start, $record) = @_; push @tables_seen, $start; my @records = ("$record"); CHILD: foreach my child (keys %{$db->{$start}{$record}{children}}) { next CHILD if grep /$child/, @tables_seen; my @child_values; foreach my $key (keys %{$db->{$start}{$record}{children}{$chil +d}}) { push @child_values, traverse_nodes($db, $child, $key); } my @temp = @records; @records = (); foreach my $rec (@temp) { push @records, map { "$rec $_" } @child_values; } } return @records; } my $starter = 'table a'; my @good_records; foreach my $record (keys %{$rdb->{$starter}}) { @tables_seen = (); push @good_records, map { join "", $_ } traverse_nodes($rdb, $starter, $record); } print "REC: $_\n" foreach @good_records;
------
/me is the brightest bulb in the chandelier!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Q: So you think you're good with structures? A: Umm... Yes!
by clintp (Curate) on Aug 04, 2001 at 04:13 UTC | |
by dragonchild (Archbishop) on Aug 06, 2001 at 16:45 UTC | |
|
Re: Q: So you think you're good with structures? A: Umm... Yes!
by clintp (Curate) on Aug 06, 2001 at 22:04 UTC | |
by dragonchild (Archbishop) on Aug 06, 2001 at 22:28 UTC |