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.
|
|---|
| 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 |