Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The code below had some code removed to make it easier to follow. I'm trying to loop over the chunk until I have twice as many pictures as I asked it to find. It finds pictures, lots of them, but doesn't STOP finding them once it goes over 2X.
I know it's finding enough because I'm printing $pics_found each time through and it's way, way high.
If someone can fix THIS problem for me, that'd be great. Else I tried to do a workaround by adding a conditional near the top of the loop if ($pics_found >= $pics_to_find * 2). I tried using last and it kept going over and over again (it never found more pictures but it printed out Finished finding... forever. I then added exit and it then, well, exitted the whole script. How do I make the conditional make the while() stop?
while($pics_found <= $pics_to_find * 2) { foreach my $gal (@gals) { if ($pics_found >= $pics_to_find * 2) { print "\nFinished finding enough pictures ($pics_found)."; exit; } $pics_found = $#pics + 1; print "\nMoving on to next gallery. Currently found $pics_found +pics"; } if ($pics_found < $pics_to_find * 2) { print "We ran out of pictures to find for this search query."; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while loop not stopping
by johngg (Canon) on May 16, 2007 at 15:34 UTC | |
|
Re: while loop not stopping
by ropey (Hermit) on May 16, 2007 at 15:25 UTC | |
|
Re: while loop not stopping
by swampyankee (Parson) on May 16, 2007 at 15:44 UTC |