use IO::File; my $fh = IO::File->new("/tmp/myprocess.tmp", "w"); if (defined $fh) { ... $fh->close; }