use strict; print &openit; sub openit1 { use Fcntl qw(O_CREAT O_EXCL O_WRONLY); my $fp = "c:\\temp\\test.csv.lck.tmp"; die "Cannot open $fp" if !sysopen (my $fh,$fp,O_WRONLY|O_CREAT|O_EXCL); close $fh; unlink $fp; return $fp; } #### use strict; print &openit; sub openit { eval "use Fcntl qw(O_CREAT O_EXCL O_WRONLY);"; my $fp = "c:\\temp\\test.csv.lck.tmp"; die "Cannot open $fp" if !sysopen (my $fh,$fp,O_WRONLY|O_CREAT|O_EXCL); close $fh; unlink $fp; return $fp; }