seaver has asked for the wisdom of the Perl Monks concerning the following question:
LINE refers to the while loop that is looping through the file, and each $line of the file, if it meets the requirements, is used.while( my ($res, $ats) = each %{$self->{'residues'}{$modelCount}} ) { if($ats eq $line){ do stuff to $line; last LINE; } }
However, the inner while loop shown above does not reset itself, consequently, the next $line doesnt have stuff happening to it, because no $ats matches it, THEN, because the while loop reaches the end of the hash, it goes back and does it again, but to the NEXT line in the file.
The result of which seems like this loop is skipping every other $ats
I'm trying to find information on resetting while loops, but, though I've found something on making the $_ local, it doesnt seem to apply here?
Anyone know what to do?
Cheers
Sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reset while loop to beginning of hash when using 'each'
by davido (Cardinal) on Sep 25, 2003 at 23:23 UTC | |
by seaver (Pilgrim) on Sep 26, 2003 at 21:24 UTC | |
|
Re: Reset while loop to beginning of hash when using 'each'
by Nkuvu (Priest) on Sep 25, 2003 at 23:25 UTC | |
|
Re: Reset while loop to beginning of hash when using 'each'
by BrowserUk (Patriarch) on Sep 25, 2003 at 23:25 UTC | |
|
Re: Reset while loop to beginning of hash when using 'each'
by perlmonkey (Hermit) on Sep 25, 2003 at 23:31 UTC |