As a side note, I wonder wether perl could emit a warning when one tries to open() an anonymous file for reading (or for writing) only... or are there common situations in which it could be desirable to do so?
Perl doesn't warn on deliberate features, whether common or not. Perl autovivifies undefined filehandles, and array and hash references, and allows you to do my $var; $var += 3; without warning as well. They are all features.
Sorry, but you misunderstood what I meant, or maybe I didn't express myself clearly.

I'm not referring to autovivification et similia in general, of which I am aware too and that I consider to be great features myself as well.

I am referring to a particular, "special" open() feature, and in particular that of opening an an anonymous FH when it is passed undef as a third argument with the three-args form of call.

You'll notice that the example given in the doc itself is with mode '+>', that it says one can also use '+<' instead, but it gives a warning about it.

The cmt I made was about opening such anonymous files in '<' (or '>') mode, which could have a sense if the FH is subsequently duplicated, but which is likely, IMHO, not to be what the average user would want in the first place...


In reply to Re^2: I've been bit in the neck by open() by blazar
in thread I've been bit in the neck by open() by blazar

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.