$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.
In reply to Re: Strange Log
by chromatic
in thread Strange Log
by PixelRat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |