Perl’s sysopen

Perl’s sysopen is a function equivalent to C’s fopen. Specify a file handle for the first argument, a file name for the second argument, and an open flag for the third argument. If necessary, you can specify the permission in octal in the fourth argument, and the default permission is 0666.

#!/usr/bin/perl --

use strict;
use warnings;

print "Content-type:text/html\n\n";
use Fcntl;

my $file = test;

sysopen(my $fh, $file, O_WRONLY | O_EXCL | O_CREAT)
  or die "Couldn't open $file : $!";
close($fh);

あれ、上手くいかない。。
sysopen関数を使えば、オープンモードを細かく指定できるらしいが。。ぬぬ。