in reply to Re^3: Rename the text file WRT String
in thread Rename the text file WRT String
a) I failed to recognize it wasn't the OP who posted this code. Ahem. Oops.
b) I'm aware that rename has portability issues, but in this case it's pretty safe to use it because the requirements specify the rename must happen to a file and the file name changes, but not the location. Since we closed the filehandle before, the 'open file' issue does not apply either. Other issues may apply, but this is the OPs responsibility to figure out since we do not know the environment and requirements.
c) nitpick: Your manual rename didn't since there was no unlinking of the old file. I'm sorry to say that but it was just a very inefficient copy, which may even silently generate garbage output in case the disk space gets exhausted while copying. (The OP didn't give any clue how large the files are.)