Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Console output != file output

by toolic (Bishop)
on Sep 01, 2013 at 17:53 UTC ( #1051836=note: print w/ replies, xml ) Need Help??


in reply to Console output != file output

Tip #1 from the Basic debugging checklist: warnings

print() on closed filehandle FH at

You are opening the file for input, not output: see open. This works for me:

use warnings; use strict; my $type = 123; open (FH, '>out.txt'); print FH "start" . $type . "end"; close FH;


Comment on Re: Console output != file output
Select or Download Code
Replies are listed 'Best First'.
Re^2: Console output != file output
by perlaintdead (Scribe) on Sep 02, 2013 at 15:09 UTC

    He should be doing 3 arg open and would be best if he change that file handle to a var. Just some best practices.

    use warnings; use strict; my $type = 123; my $FH; open ($FH, '>', 'out.txt'); print $FH ("start" . $type . "end"); close $FH;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2015-07-29 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls