use POSIX; my $perms = (stat "file")[2]; sysopen(OUT, "newfile", O_CREAT | O_WRONLY, $perms) or die "$!\n"; print OUT "whatever\n"; close(OUT);