13.2 Renaming a File
In the UNIX shell, you change the name of a file with the
mv
command. With Perl, the same operation is denoted with
rename("fred","barney") || die "Can't rename fred to barney: $!";
Like most other functions,
The
mv
command performs a little behind-the-scenes magic to create a full pathname when you say
mv file some-directory
. However, the rename("
Note that in Perl we had to say the name of the file within the new
directory explicitly. Also, the
mv
command
copies
the file when the file is renamed from one mounted device to another (if you have one of the better operating systems). The |
|