The checking is always worth doing, imho.

Even if careful thought and analysis demonstrate that current versions of perl can't return an error, unless the docs give an explicit guarantee it won't fail I'd say that the behaviour is subject to change in future versions. (And said careful thought and analyis is more work than checking the error return anyway...)

Maybe a future implementation of "open scalar" likes to have a dummy unix fd behind the scenes, to remove special cases in some codepaths and your process hit's it's limit? (Or other very hypothetical situations - who can come up with the most inventive?).

Of course, if there were a significant benefit to dropping the error handling (or if you're in an environment where you don't care much), then fine. But that's true of anything, even exploiting explicitly undefined behaviour like my $foo if 0;.


In reply to Re: Checking success of open() on file held in scalar ref. by jbert
in thread Checking success of open() on file held in scalar ref. by johngg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.