This is not quite what the OP asked. From perlrun:
-i[extension]
specifies that files processed by the `<>' construct
are to be edited in-place. It does this by renaming
the input file, opening the output file by the
original name, and selecting that output file as the
default for print() statements. The extension, if
supplied, is used to modify the name of the old file
to make a backup copy, following these rules:
Meaning that -i basically does the same 'trick': open for read, edit, write back. |