Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
When run, if $limit_img_size eq "yes" it will do nothing but load until judgement day or until my server decides it's time to kill it. If I change it to "no" to catch the else, the else section works as intended.
A little background on the script: It goes to ImageFap which is a free image host with free searchable galleries. I am doing a search on it and pulling back all the galleries of results on the first page. From here, I go through the galleries one at a time and extract the image links from within the gallery. All I'm collecting are image links but I need to make sure all my image links have images of a specific size or less if that's what the user wants.
my $pics_found = $#found_images + 1; if ($limit_img_size eq "yes") { while ($pics_found < $pics_to_find * 30) # get more than needed so + we can randomly choose images later { my $next_gal = pop(@found_galleries); # remove one gallery link a +t a time until we're done if (!$next_gal) { last; } my $get_gal = get($next_gal); while ($get_gal =~ m#(http://images\.imagefap\.com/images/thumb/\ +d+/\d+/\d+\.jpg)#g) { print "1 - $1<br>"; #testing, doesn't print my $image = get($1); print "found $image<br>"; #testing, doesn't print my ($height, $width) = imgsize(\$image); push @found_images, $image if ($height <= $max_height and $width <= $max_width); } } } else { while ($pics_found < $pics_to_find * 30) { my $next_gal = pop(@found_galleries); if (!$next_gal) { last; } my $get_gal = get($next_gal); ######### # collect our image links ######### push @found_images, $get_gal =~ m#http://images\.imagefap\.com/im +ages/thumb/\d+/\d+/\d+\.jpg#g; $pics_found = $#found_images + 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: endless loop problems
by japhy (Canon) on Jun 28, 2006 at 16:00 UTC | |
|
Re: endless loop problems
by ikegami (Patriarch) on Jun 28, 2006 at 16:09 UTC | |
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 | |
by Anonymous Monk on Jun 28, 2006 at 19:47 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 20:35 UTC |