while () { if (/somematch/) { $_=~s/somematch/replace/; print FILE "$_"; } else { next; } }