in reply to Strange Log
$text = $text . $1 . "\n";
Since $text is effectively a global variable, it will always get longer. If you were to do something more like this, you wouldn't have this trouble:This ensures that $text is cleared on every iteration of the outer loop.while (1) { # get webpage my $text; while (<TEXT>) { if (/src=([^>]*)>*$/i) { $text .= "$1\n"; } # continue as normal sleep 30; } }
Stylewise, there are more Perlish ways to grab webpages. You might like the LWP library, especially LWP::Simple. It really is as simple as the name says. Also, don't forget to check the results of your open calls. They may fail.
Update: Removed spurious forward whack in regex. There's no need for the anchors, greedy match anythings or the ignore whitespace and match all flags. They don't really hurt anything, though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Strange Log
by PixelRat (Sexton) on Nov 25, 2001 at 03:46 UTC |