in reply to to write string to a temp file

I guess with "pass the file" you mean "pass the filehandle"? That should not be a problem. The following

perl -e 'use File::Temp; $fh = File::Temp->new(); $fh->unlink_on_destr +oy(0); bo($fh); sub bo { my $f= shift; print $f "test"; }'

creates a file in /tmp with the string test in it.

You might show us your code, generally it works