http://qs1969.pair.com?node_id=558046


in reply to endless loop problems

Your basic problem is that you're not updating $pics_found in your top while loop, like you are in the bottom loop. By the way, $pics_found = $#found_images + 1 is an ugly way of saying $pics_found = @found_images, since an array in scalar context returns its size. There's really no need for a separate variable, then! Also, move your $limit_img_size logic to the inside of the while loop. The two loops do the same thing, there's just a slight bit of extra logic if $limit_img_size is "yes".
while (@found < $pics_to_find * 30) { last unless @found_galleries; # exit the loop if there are no more my $gallery_content = get(pop @found_galleries); while ($gallery_content =~ /.../) { ... # why use "yes" and "no"? why not just a true value or a false va +lue? next if $limit_img_size eq "yes" and !some_size_constraint(); push @found, ...; } }

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart