use strict; use warnings; while () { while (/(\bSPORT\b.*?\bEND\b)/g) {print "$1\n"} } __DATA__ your long line here