use warnings; use strict; $/ = "_END=======\n"; while () { s/========KEYWORD.+\n//g; print '-' x 80, $_, '-' x 80; $text = $_; }