My script writes a txt file after running. The script is as follow.
---------------------------------------------
open(LOG,"today.txt");
flock(LOG, 2);
@lines = <LOG>;
close(LOG);
open(DATA,">yesterday.txt");
flock(DATA, 2);
print DATA @lines;
close(DATA);
unlink("today.txt");
---------------------------------------------
sometimes, yesterday.txt turn to a clear txt file, although today.txt contains some words. All words are deleted in this process. So... How can I modify the code to prevent yesterday.txt from losing information??
Thanks.
---------------------------------------------
open(LOG,"today.txt");
flock(LOG, 2);
@lines = <LOG>;
close(LOG);
open(DATA,">yesterday.txt");
flock(DATA, 2);
print DATA @lines;
close(DATA);
unlink("today.txt");
---------------------------------------------
sometimes, yesterday.txt turn to a clear txt file, although today.txt contains some words. All words are deleted in this process. So... How can I modify the code to prevent yesterday.txt from losing information??
Thanks.