in reply to Strange Log

It's only doing what you ask it to do:

$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:
while (1) { # get webpage my $text; while (<TEXT>) { if (/src=([^>]*)>*$/i) { $text .= "$1\n"; } # continue as normal sleep 30; } }
This ensures that $text is cleared on every iteration of the outer loop.

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
    thanks, it worked, but i had to change it a bit to:
    my $text; while (<TEXT>) { if ($_ =~ /^.* src=([^>]*)>.*$/ixg) { $text .= "$1\n"; } }
    when i ran your example i got a syntax error near "/) "