[Omaha.pm] rename, link

Jay Hannah jhannah at omnihotels.com
Fri May 19 08:31:28 PDT 2006


Huh. "perldoc perlfunc":

       rename OLDNAME,NEWNAME
               Changes the name of a file; an existing file NEW-
               NAME will be clobbered.  Returns true for success,
               false otherwise.

               Behavior of this function varies wildly depending
               on your system implementation.  For example, it
               will usually not work across file system bound-
               aries, 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 documenta-
               tion for details.

So I wonder if its better to just system() out to "mv" on Linux if I
don't care about portability?

  @sysargs = ('mv', "$outbound/$file",
"/datamining/intrasight/CRS/archive");
  system (@sysargs);

vs

  rename("$outbound/$file", "/datamining/intrasight/CRS/archive/$file");

...?

And then 

       link OLDFILE,NEWFILE
               Creates a new filename linked to the old filename.
               Returns true for success, false otherwise.

Is that the same thing as making a system() call to "cp" on Linux?
symlink() is for symbolic links, link() is the same thing as "cp"?

Or would I be cooler if I just used some File::* class off CPAN
nowadays? -grin-

j



More information about the Omaha-pm mailing list