in reply to endless loop problems
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: endless loop problems
by coldfingertips (Pilgrim) on Jun 28, 2006 at 16:18 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 16:28 UTC | |
by coldfingertips (Pilgrim) on Jun 28, 2006 at 16:33 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 16:46 UTC | |
|
Re^2: endless loop problems
by Anonymous Monk on Jun 28, 2006 at 19:47 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 20:35 UTC |