http://qs321.pair.com?node_id=857875


in reply to Re^2: Printing to a File from Sub
in thread Printing to a File from Sub

Putting the filehandle in parens told Perl that it is the argument to print, and so you wanted to print it to STDOUT - which is not what you wanted. You wanted to say
print $fhout "this is a test\n";
It should also be noted that the variable $fhout is actually still in scope in your subroutine, so you technically could just use it. It is, however, better practice to pass it in.

Edit: choroba is correct as s/he notes below. I did mistake the curlies for parens.