in reply to Re: Creating loop on undefined hash key value
in thread Creating loop on undefined hash key value

Thanks for the reply...

The only problem with the code you provided is that it does not deal with newly added keys (within the loop). The trick I'm looking for is the have the loop deal with new entries as well as those the pre-existed in the hash before the loop was started.

Maybe a WHILE clause..hmmm. I need to think about this some more. There has to be a general way to deal with a dynamic hash loop, you'd think.

Any other ideas???

======================
Sean Shrum
http://www.shrum.net

  • Comment on Re: Re: Creating loop on undefined hash key value

Replies are listed 'Best First'.
Re: Re: Re: Creating loop on undefined hash key value
by Courage (Parson) on Nov 24, 2002 at 08:19 UTC
    in case you need to deal with newly added keys, I'll suggest you to create a simple stack and loop until it's empty:
    for (my @stack = keys %links; $#stack>=0; ) { my $current = shift @stack; next if $links{$current}{visited}; if (something_happens()) { push @stack, "another key"; } }

    Courage, the Cowardly Dog