# If you need the stuff in @data_out my @data_out; while () { next if /^\*{4}200[^6]/; push @data_out, $_; } print @data_out; #### # If you don't need @data_out while () { print unless /^\*{4}200[^6]/; } #### # If you want something easy to read and # don't mind loading the entire file into memory. print grep { !/^\*{4}200[^6]/ } ;