[Za-pm] Writing a search replace script

Spike spikeh at mweb.co.za
Thu Feb 26 02:07:52 CST 2004


I knew there had to be a reason!

At 2004/02/26 09:06 AM, Oskar Pearson wrote:
>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
>_______________________________________________
>Za-pm mailing list
>Za-pm at mail.pm.org
>http://mail.pm.org/mailman/listinfo/za-pm


Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
083 294 9593
Fax 0866721733


Click here and make M-Web your homepage
http://homepage.mweb.co.za  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20040226/9d8c357f/attachment.htm


More information about the Za-pm mailing list