#!/usr/bin/perl while ( defined ( $_ = <> ) ) { print; if ( /^line before your replacement/ ) { <>; print "LocalCompilerPresent=0\n"; } }