From this example it looks like it would be easy to print to output ...
As a first step, create a small test input file and just print the altered and unaltered lines to standard output, e.g.,
print $my_new_line_what_is_just_the_way_i_want_it;
When this limited, test output looks ok, start to think about the process of opening a new file and writing to that file instead of STDOUT. When that looks ok, start thinking about all the input/output file verification and renaming that has to happen. (I'm sure there are modules to facilitate the "edit in place" process, but I don't know what they are off-hand.)
Give a man a fish: <%-(-(-(-<