Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: forgoing explicit file close

by sundialsvc4 (Abbot)
on Aug 23, 2015 at 15:13 UTC ( #1139583=note: print w/replies, xml ) Need Help??


in reply to forgoing explicit file close

Agree .. agree .. agree .. upvote .. upvote .. upvote.

The entire process of handling a file is fraught with potential errors:   opening it, read/write, seek, and close..   Your code therefore needs to explicitly do all of it, and to explicitly check for errors.   You might have “successfully written” a bunch of data to the file, not realizing that it’s still in Perl’s buffers, when the file has gone away and the problem will not be detected until Perl attempts to write those buffers (e.g. at close time).   Even if a warning message is produced, that is not something that your program can intercept and react to ... so, that’s not good enough.   Your program will behave “mysteriously,” and that’s what causes the pager to go-off in the middle of the night or when you are having ... well, anyway ...   ;-)

Never let Perl do such things “by default.”   Code like that only works when it works.

Replies are listed 'Best First'.
Re^2:forgoing explicit file close
by 1nickt (Abbot) on Aug 23, 2015 at 15:24 UTC

    Since it's Sunday ...

    From Psycho Killer, Talking Heads, © David Byrne 1977:

    You're talking a lot, but you're not saying anything. When I have nothing to say, my lips are sealed. Say something once, why say it again?
    The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2019-04-20 22:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (110 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!