Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 imbibing at the Monastery: (4)
As of 2021-05-09 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (100 votes). Check out past polls.

    Notices?