in reply to recursive difficulty
Second, instead of popping things off of the array (in the hash) and thus changing the data in the structure, I would use a construct like the following,so that the data structure stays intact and thus there would be no reason to rebuild it. What I mean is that, instead of this:use strict; use warnings; get_data(); get_data(); sub get_data { while ( <DATA> ) { print $_; } } ##get_data __DATA__ A B C D
I would do something like this instead:while(1){ last unless my $immed = pop @{$immed_child{$root}}; get_descends($immed); $all_descends{$immed}++; }
Anyhow, I hope this helps.foreach my $immed ( @{$immed_child{$root}} ) { get_descends($immed); $all_descends{$immed}++; }
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2: recursive difficulty
by jjohhn (Scribe) on Mar 09, 2003 at 23:57 UTC | |
by pg (Canon) on Mar 10, 2003 at 00:05 UTC | |
by jjohhn (Scribe) on Mar 10, 2003 at 00:32 UTC | |
by theorbtwo (Prior) on Mar 10, 2003 at 02:59 UTC | |
by Hofmator (Curate) on Mar 10, 2003 at 09:25 UTC |