Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do I write to a file?

by revdiablo (Prior)
on Jun 23, 2003 at 00:19 UTC ( #268012=note: print w/replies, xml ) Need Help??


in reply to How do I write to a file?

The 3-arg form of open is fairly useful to prevent problems with filenames "tricking" perl, and other nasty surprises:

open FH, ">", $outfile or die "Error writing '$outfile': $!\n"; print FH $output; close FH;

Also useful are lexical filehandles:

open my $filehandle, ">", $outfile or die "Error writing '$outfile': $ +!\n"; print $filehandle $output; close $filehandle;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2021-04-16 18:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?