use CGI qw(:standard); if ($ENV{'REQUEST_METHOD'} eq "POST") { my $data = param('snoop'); unless ($data) { # Tasty honey open(DENY, ">>.htaccess") or die "Tried to add host (" . $ENV{REMOTE_ADDR} . ") to deny list, but failed to open file\nError: " . $!; flock(DENY, 2); # <-- Lock the file print DENY "Deny from " . $ENV{REMOTE_ADDR} . "\n"; close(DENY) or die "Tried to close deny list but failed (Host: " . $ENV{REMOTE_ADDR} . ")\nError: " . $!; die; } }