use warnings; use strict; while () { print if (/start/i .. /end/i) } __DATA__ foo start checking script end foo #### if (/start/i .. /end/i) { print unless /start/i or /end/i; }