> On Sat, 4 Dec 2004, Felix Li wrote: > > > It's fairly well known that one should use "open" with an "or die". Is > > there really any condition where "close" fails, making the "or die" > > necessary? > > Of course! > > Off the top of my head, there are two obvious possibilities: > > * The file might not exist; maybe it somehow got deleted, > or maybe it never existed to begin with. > > * File permissions may prevent you from opening it. ...deletia... > The 'open ... or die ...' idiom makes debugging *much* easier. > >
If you re-read the question carefully: >> Is there really any condition where "close" fails ... ? I can imagine filesystem semantics that would allow a close to fail ... If the file has some un-trapped error condition from a previous read or write operation, the OS may post an error when you attempt to close. Another possibility (although far-fetched): What if the filesystem goes away while you had it open? -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is required is to sort them into the correct order. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>