Re: opening a file



On Jan 10, 8:07 am, Tad J McClellan <ta...@xxxxxxxxxxxxxx> wrote:
You should always, yes *always*, check the return value from open():

Like other ironclad rules, this also has exceptions. Using the 'or
die' construct has costs (albeit minimal) and when the costs outweigh
the benefit, you shouldn't use it. Example: opening the file is
tangential to the script so you don't care whether the file opens but
you DO care if the script dies.

It's true that in the vast majority of cases a prudent script will
perform error checking for open(), but it's also true that one
shouldn't follow the rule blindly forgetting the purpose and the
effects of error checking.

CC
.



Relevant Pages

  • Re: opening a file
    ... Like other ironclad rules, this also has exceptions. ... die' construct has costs and when the costs outweigh ... but checking the return value doesn't mean to die if it fails to ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (comp.lang.perl.misc)
  • Re: opening a file
    ... die' construct has costs and when the costs outweigh ... If you don't care whether the file opens, ... Not every instance of checking what openreturns is done with "or die". ... If you don't want the script to die, ...
    (comp.lang.perl.misc)
  • Re: opening a file
    ... Like other ironclad rules, this also has exceptions. ... probably have difficulties even measuring the additional cost of die. ... tangential to the script so you don't care whether the file opens but ... Then don't use die() but some other appropriate error handling, ...
    (comp.lang.perl.misc)
  • Re: opening a file
    ... Like other ironclad rules, this also has exceptions. ... The "check the return value" part was meant to be ironclad. ... The "what action to take part" (eg. die) was not meant to be ironclad. ... tangential to the script so you don't care whether the file opens but ...
    (comp.lang.perl.misc)