[regex] How to replace a string in an existing file in Perl?