> Well, what was your $! when the rename failed?  If it was "cross-device link",
> then you attempted something that you really can't do.

I don't think it was anything like that, as with many :) real world
problems, it's a bit more complicated than that. The file in question on my
failure was an email subscription list, so an email had to be searched for
in one file, a new version of this file had to be created that had the
file's content sans found email and then this list had to be written back
into where it used to be, so it was something like (reduced to Algorythmic
fluff for clarity):


------------------------------

open OLDFILE, $oldfile;
open TEMPFILE, $tempfile;

while TEMPFILE  
    next if $email eq '$_';
    print TEMPFILE $_;
end while
 
close OLDFILE; 
close TEMPFILE;

delete($oldfile); 
# ahem
rename($tempfile, $oldfile);

------------------------------
a BIG problem with this was that the live file with the subscription list
was hit several times a second for large lists which also makes the file
kinda hefty. so, yeah, this was just asking for trouble.

My solution was to first make my Highlander, 'There shall be only one' temp
file lock and with that protection, make my temp file with the changes,
close both the temp and live file, open the live file for overwritting, and
the temp file for reading, and then just delete the temp file.

I'm pretty happy with the performance, as the site that was really having
problems.. hasn't since we changed this routine and their list is somewhere
around 70,000 - 100,00, this site is http://redjellyfish.com the software is
(*cough* shameless plug) http://mojo.skazat.com
-- 

justin simoni 

personal musings ~  http://skazat.com
_____________________________________
                  force a change





On 9/10/01 8:04 PM, "Randal L. Schwartz" <[EMAIL PROTECTED]> wrote:

>>>>>> "Justin" == Justin Simoni <[EMAIL PROTECTED]> writes:
> 
>>> Yes, and surprisingly enough, it's called "rename". :)
> 
> Justin> I've had bad luck using rename, I've had to copy the file to
> Justin> the new name and deep six the old, check out File::Copy, I
> Justin> think it ironically, has a function called copy(), or even
> Justin> cp(), my memory eludes me.
> 
> Well, what was your $! when the rename failed?  If it was "cross-device link",
> then you attempted something that you really can't do.
> 
> But to say in general that "rename" is perhaps broken is a bit too
> much for me to let stand with no comment.
> 
> My advice to the original poster: use rename, but be aware that it can
> only rename within a disk, not across disks.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to