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


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

You should either use
open my $fhout, '>', "./test_out.file" or die "$!";
or
open (my $fhout, '>', "./test_out.file") || die "$!";
. The code you posted is parsed as
open (my $fhout, '>', ("./test_out.file" || die "$!"));
which is definitely not what you want.

To avoid the error you reported, though, use

my ($fhout) = @_;
or
my $fhout = shift;
Also note that the ampersand sign & is not needed when calling a sub (see perlsub).