unless (-e $file) { open FILE, "> $file"; # ... } #### use POSIX qw( O_EXCL O_CREAT ); $perm = 0644; # or whatever sysopen FILE, $file, O_EXCL | O_CREAT, $perm or die "can't create $file: $!";