while (1) { # get webpage my $text; while () { if (/src=([^>]*)>*$/i) { $text .= "$1\n"; } # continue as normal sleep 30; } }