in reply to Unique filehandle -- what is correct?
This is a common task, try a module like File::Temp.
If you have perl 5.6.1 or newer, it is already installed.
In your case, use UNLINK => 1 to automatically remove the temp. file
after program execution. There are more options that let you fine-tune the
filename format/suffix, the directory and so on.
use File::Temp qw(tempfile);
#-- UNLINK => 1: removes the tempfile when program finishes
# perldoc File::Temp - shows more usage options
my ($fh, $filename) = tempfile( UNLINK => 1);
#-- that's it - now display filename...
print "Filenme: $filename\n";
#-- or use filehandle... (here: no open()/close() required!)
print $fh "lalala\n";
#-- here: file is removed automatically on program exit