my $path = "$dir/$name"; my $fh; use Fcntl; sysopen ( $fh, $path, O_WRONLY|O_EXCL|O_CREAT|O_EXLOCK ) or die $!;