open(TST, "test.log") or dir $!; while () { chomp; if (/start/ .. /end/) { s/.*(start.*end).*/$1/m; print "$_\n"; } }