The problem is that you never update $pics_found. Replace $pics_found with @found_images.
I see that you tried to debug the problem by adding print statements. That's good. (We like monks that put in some effort, and it's what I would have done.) The problem with your print statements is that they are being buffered. Adding $| = 1 will reveal them.
I took the liberty of cleaning up your code:
# $| = 1; # Uncomment when adding print statements for debugging. # Get more than needed so we can randomly choose images later. while (@found_galleries && @found_images < $pics_to_find * 30) { # Remove one gallery link at a time until we're done. my $gal_url = pop(@found_galleries); my $gal = get($gal_url); # Extract the image URLs from the gallery page. my @image_urls = $gal =~ m#(http://images\.imagefap\.com/images/thu +mb/\d+/\d+/\d+\.jpg)#g; # Remove the images which are too big. if ($limit_img_size eq "yes") { @image_urls = grep { my $image = get($_); my ($height, $width) = imgsize(\$image); $height <= $max_height && $width <= $max_width } @image_urls; } push @found_images, @image_urls; }
In reply to Re: endless loop problems
by ikegami
in thread endless loop problems
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |