open '+<', '## 1 2 3 4 5 #### 1 two hi hello 3 4 5 #### open FH, '+) { print $_; if ( /^2/ ) { print FH "two\nhi hello\n"; } } #### 1 2 two hi hello