in reply to Modifying lines of text

All you need is really a one liner

perl -pi -e 's/line2/changed_line2/'

see perldoc -q insert for more examples and the equivalent expanded code. see also the note on one liners in windows if you are in windows

HTH

-T

use perl; use strict;