NeilFawcett
Programmer
I'm periodically getting corrupted records from my perls scripts. They are blank, etc. I recon this could be down to when the system hiccups/crashes and my perl scripts happen to be running at the time...
Is this the most reliable/best way to process a text file?
Can anyone suggest anything that can improve on this and make it any more reliable?
Is this the most reliable/best way to process a text file?
Code:
#!/usr/bin/perl
use Fcntl qw(:DEFAULT :flock);
print "Content-type: text/html\n\n";
sysopen(AC,"test.txt", O_RDWR | O_CREAT) or die "message";
flock(AC,LOCK_EX) or die "message";
@recs=<AC>;
#Update @recs in someway
seek AC,0,0;
print AC @rec;
truncate(AC,tell(AC)) or die "message";
close(AC) or die "message";
Can anyone suggest anything that can improve on this and make it any more reliable?