Or, you could visit the perldoc documentation for
rename.
On a side note from the link that Arepi provided, in there the example they show uses a print statement to show an error if the rename didn't work. Personally, I would rather use the die() function instead of the print, like so:
-
rename("file.txt", "newfile.txt") || die "Cannot rename file: $!";
-
The $! in the die function prints the actual error received from the attempted rename if it fails. This is usually a bit more helpful.
Regards,
Jeff