in reply to Deleting files

I think the question you are asking is whether you can get the name of the file from its file handle.

The answer is no.

Unfortunately you have to keep track of the names of your temporary files. You can store them in a list, perhaps, when they are first created with:
push @tempfiles, $tmpfilename;
and then remove them at the end with:
unlink @tempfiles;
Another method is to put your temporary files under a temporary folder created by your script, and simply prune the temporary folder at the end of processing.

Update: And yes, you can rewrite your script using File::Temp as pointed out by merlyn.