Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Printing to a File from Sub

by choroba (Cardinal)
on Aug 30, 2010 at 16:47 UTC ( [id://858046]=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://858046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-29 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found