I have a banner impression counter.
But when I try to lock the counter file the script doesn't
work. What I am doing wrong?
use Fcntl qw(:flock); # import LOCK_* constants
if ( -e $file_banner)
{
open(COUNT,"$file_banner") || die print "Could not open for read";
# flock(COUNT,LOCK_EX) || die print "Could not lock";
$line = <COUNT>;
# flock(COUNT,LOCK_UN) || die print "Could not unlock";
close(COUNT);
print "a:$line";
$line++;
print "b:$line";
open(COUNT,"+< $file_banner") || die print "Could not open for wri
+te";
# flock(COUNT,LOCK_EX) || die print "Could not lock";
print COUNT "$line";
# flock(COUNT,LOCK_UN) || die print "Could not unlock";
close(COUNT);
}
else
{
open(NEW,"> $file_banner");
print NEW "0";
close(NEW);
print "ffff\n\n";
}
exit;