in reply to Re: Can I include O_CREAT, O_EXCEL and O_WRONLY in my script without always requiring Fcntl?
in thread Can I include O_CREAT, O_EXCEL and O_WRONLY in my script without always requiring Fcntl?

Thank you! That appears to work. My test program would then look like this:
use strict; print &openit; sub openit { eval "use Fcntl qw(O_CREAT O_EXCL O_WRONLY);"; die $@ if ($@); my $fp = "c:\\temp\\test.csv.lck.tmp"; die "Unable to open $fp" if !sysopen (my $fh, $fp, O_WRONLY() | O_CR +EAT() | O_EXCL()); close $fh; unlink $fp; return $fp; }

Thanks again.

Richard

  • Comment on Re^2: Can I include O_CREAT, O_EXCEL and O_WRONLY in my script without always requiring Fcntl?
  • Download Code

Replies are listed 'Best First'.
Re^3: Can I include O_CREAT, O_EXCEL and O_WRONLY in my script without always requiring Fcntl?
by salva (Canon) on Apr 13, 2006 at 18:13 UTC
    you can also eliminate the eval/use statement replacing it by a require one and then call the constant subs prefixed with the package name:
    sub openit { require Fcntl; my $fp = "c:\\temp\\test.csv.lck.tmp"; die "Unable to open $fp" if !sysopen (my $fh, $fp, Fcntl::O_WRONLY() + | Fcntl::O_CREAT() | Fcntl::O_EXCL()); close $fh; unlink $fp; return $fp; }