Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Implicit closing of files

by johngg (Canon)
on Jun 17, 2008 at 10:51 UTC ( [id://692464]=note: print w/replies, xml ) Need Help??


in reply to Implicit closing of files

I'm not sure whether there might be problems on a Windows platform, I generally use Solaris and have not had problems with implicit closing. However, I would advise the use of lexical filehandles plus the three-argument form of open and a check for success.

{ { open my $fh, q{>}, q{outfile.txt} or die qq{open: > outfile.txt: $!\n}; print $fh qq{ ... }; } }

I hope this is of interest.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Implicit closing of files
by rovf (Priest) on Jun 17, 2008 at 11:14 UTC
    3-arg open is for sure the better alternative in general, because there is no problem with "funny characters" in the filename, which could change the meaning of the open. In my concrete case however, this turns out not to be a problem.
    -- 
    Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found