What's wrong with it
Code:
#!/usr/bin/perl -w
use CGI qw(:all);;
use Fcntl qw(:flock);
my $mldata="onemoretime.txt";
my $semaphore_file="onemoretime.txt";
$file='SnPmaster.txt';
open(INFO, $file) or die("Could not open file.");
$count = 0;
foreach $line (<INFO>) {
print $line;
if ($++counter == 2){
last;
}
}
close(INFO);
sub get_lock {
open(SEM, "$onemoretime.txt") || die "Cannot open $onemoretime.txt : $!";
flock SEM, LOCK_EX;
}
#
sub release_lock {
close(SEM);
}
get_lock();
open(GB, ">>$mldata") || die "Cannot open $mldata: $!";
print GB "address: ", param('_ADDRESSVARIABLE'), "\n";
close(GB);
release_lock();
}