in reply to How to allow loop to continue to run after a problem opening a file

Hmmm -- I think you mean you want to skip the code in the loop after the get fails and "get" the next file instead? I suppose you could use an inclusive "if", but the simplest way is probably with "next":

while($urllist =~ m{(http://.+\.html)}g){ my $url=$1; my $html = get("$url"); unless ($html) { print "Couldn't fetch $url."; next; } while($html=~ m{(find whatever I want)}gi){ $mysearch=$1; print output "$url|$mysearch\n";} } }

"next" just means to move on to the next iteration of the loop, skipping any subsequent code.

  • Comment on Re: How to allow loop to continue to run after a problem opening a file
  • Download Code

Replies are listed 'Best First'.
Re^2: How to allow loop to continue to run after a problem opening a file
by rizzy (Sexton) on Oct 20, 2010 at 03:23 UTC

    Yes, I worded it wrong in the title. I am pulling out every url from a list and want to continue with the next one even if the current one is not available for download . I was unaware of the unless and next command. Thanks!