use IO::File; use POSIX qw(tmpnam); my $name; do{ $name = tmpnam() } until $fh = IO::File->new( $name, O_RDWR|O_CREAT|O_EXCL ); binmode $fh;