#!/usr/local/bin/perl -w open FH,"+; $keep_bit=0; foreach (@x) { if (/^RE$/) { $keep_bit++; } if ($keep_bit) { push(@y,$_); } } seek (FH,0,0); print FH @y; truncate(FH, tell(FH)); close FH;