$ perl test.pl test.file File has 4 lines one two three four File has 0 lines File has 2 lines replacement line here another new line