[Za-pm] Writing a search replace script

Oskar Pearson oskar at qualica.com
Thu Feb 26 01:06:09 CST 2004


Hi


> Why use move - couldn't you just use rename ("/tmp/balsa.tmp", $file )?


Check out "man perlfunc". The "move" command will work across
different mount points (so that if your /tmp directory is
on a different filesystem to the files you are manipulating,
it will still work in all cases on all systems).

rename OLDNAME,NEWNAME
Changes the name of a file; an existing file NEWNAME will
be clobbered.  Returns true for success, false other­ wise.

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


> At 2004/02/26 06:12 AM, Nico Coetzee wrote:
> ># but first make a backup copy:
> >    43          my $bakfile= $file . ".bak";
> >    44          rename( $file, $bakfile );
> >    45          move( "/tmp/balsa.tmp", $file );
> >    46          if( -e $file ) {
> >    47



More information about the Za-pm mailing list