Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: endless loop problems

by japhy (Canon)
on Jun 28, 2006 at 16:00 UTC ( #558046=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://558046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-18 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?