Hi,
I am working on a web page hit counter and information on the internet suggest the use of "sysopen" and "flock".
However, when I experimented with "sysopen" and "flock", it seemed that "flock" had no effect.
I am using Perl 5.005_03 and Aix (version 4 release 3).
The above code executed without any error message and the text "hello world 2" was written to the file.
Thanks in advance.
LeunGi
I am working on a web page hit counter and information on the internet suggest the use of "sysopen" and "flock".
However, when I experimented with "sysopen" and "flock", it seemed that "flock" had no effect.
I am using Perl 5.005_03 and Aix (version 4 release 3).
Code:
#!/usr/bin/perl
use Fcntl qw(:DEFAULT :flock);
$fname = "test.txt";
sysopen(FH1, $fname, O_RDWR|O_CREAT);
flock(FH1, 2) || die "here 1\n";
sysopen(FH2, $fname, O_RDWR|O_CREAT);
flock(FH2, 2) || die "here 2\n";
print FH1 "hello world 1\n" || die "here 3\n";
print FH2 "hello world 2\n" || die "here 4\n";
close(FH1) || die "here 5\n";
close(FH2) || die "here 6\n";
The above code executed without any error message and the text "hello world 2" was written to the file.
Thanks in advance.
LeunGi