You are viewing the version of this documentation from Perl blead. This is the main development branch of Perl. (git commit cf7cc0a627da2ab1c0e64ac5a77bd2ca9c1a4e52)
rename OLDNAME,NEWNAME

Changes the name of a file; an existing file NEWNAME will be clobbered. Returns true for success; on failure returns false and sets $!.

Behavior of this function varies wildly depending on your system implementation. For example, it will usually not work across file system boundaries, even though the system mv command sometimes compensates for this. Other restrictions include whether it works on directories, open files, or pre-existing files. Check perlport and either the rename(2) manpage or equivalent system documentation for details.

For a platform independent move function look at the File::Copy module.

Portability issues: "rename" in perlport.