use strict; use warnings; while () { next if /\[datestamp\[/; print if /crap/; } __DATA__ [datestamp] [DEBUG] something here [datestamp] [DEBUG] something else here [datestamp] [ERROR] blah blah [datestamp] [INFO] bla bla bla