samwyse has asked for the wisdom of the Perl Monks concerning the following question:

I need to create a temp file. Here's my straightforward code:
my $fh = File::Temp->new(); $fh->autoflush(1); foreach my $cmd (@_) { print "$cmd\n"; print $fh "$cmd\n"; } system "dir $fh";
When I run it, I get this:
C:> supportsave -n -h -d /incoming/50798070 -l ftp exit Volume in drive C has no label. Volume Serial Number is 32B6-C79A Directory of C:\DOCUME~1\dentos\LOCALS~1\Temp 11/30/2012 05:16 PM 0 vfmhcyNzQN 1 File(s) 0 bytes 0 Dir(s) 783,720,448 bytes free
Why is my file showing up with zero bytes? I've tried using flush at the end of the loop, and sleeping 10 seconds for the OS to catch up, but it keeps acting the same. Did I miss something obvious in the docs? Many thanks for any assistance.