CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
work backup file

 



Jimtaylor5
Deleted

Jun 4, 2000, 11:35 AM

Post #1 of 1 (530 views)
work backup file Can't Post

I am trying to write a backup to work on a file so it doesn't get corrupted when someone quits in the middle of the program, but am having problems. Can anyone tell me what is wrong with this, or give me an "example" of a more effective way of doing this?

open(ORIG,"$old");
flock ORIG, 2;
@orig = <ORIG>;
flock NEWMSG, 8;
close(ORIG);

open(BAK,">$new");
flock BAK, 2;
for each $line (@orig) {
# do some work
print BAK "$line";
}
use File::Copy;
open(ORIG,"$old");
flock ORIG, 2;
copy ("$new", "$old");
flock ORIG, 8;
close(ORIG);

flock BAK, 8;
close(BAK);

HELP! How would I do this so that my original file stops occasionally getting corrupted. Flock is working perfectly.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives