Jump to content

Perl Programming/Keywords/rename

From Wikibooks, open books for an open world
Previous: ref Keywords Next: require

The rename keyword

[edit | edit source]

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 | edit source]
  rename OLDNAME, NEWNAME

Examples

[edit | edit source]
rename "barewords.pl" "bareword.pl"
Previous: ref Keywords Next: require