while () { if (/^start\b$/ .. /^end\b$/) { print MYOUTFILE "$file;$_\n"; } }