Perl Programming/Keywords/rename

Previous: ref Keywords Next: require

The rename keyword edit

The rename function changes the file name given in OLDNAME. An existing file with the name of NEWNAME will be clobbered. Returns true on success and false otherwise.

The behaviour of the rename function varies widely, depending on the implementation on the operating system. It will often not work over file system boundaries, although mv on UNIX-like systems will sometimes work. Other restrictions may be whether it works on directories, open files, or pre-existing files.

Syntax edit

  rename OLDNAME, NEWNAME

Examples edit

rename "barewords.pl" "bareword.pl"
Previous: ref Keywords Next: require