I think I found myself in an endless loop. This is a followup of my post yesterday adding an IF to a push.

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; } }

In reply to endless loop problems by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.