in reply to to write string to a temp file

I have to pass the file (with the two strings) to other subroutines

Do you mean the file handle? For example:
use warnings; use strict; use File::Temp; sub mysub { my ($fh, $str1, $str2) = @_; $fh->seek( 0, 0 ); print <$fh>; } my $fh = File::Temp->new(); my $s1 = 'This is string one'; print $fh "$s1\n"; my $s2 = 'This is string two'; print $fh "$s2\n"; mysub ($fh, $s1, $s2);
Gives:
This is string one This is string two