in reply to Creating a file in temp folder

The others have asked the proper questions. I'm just here to suggest File::Temp.