Hi Ken not sure I understand your reply as I'm not having a specific problem with PERL or disagreeing with a document, just wanting clarification on file handle modes which I imagine is not specific to PERL. I've been a native (if infrequent) speaker of PERL for about 20 years now and have thus lost the ability to compare PERL with one of the saner languages but it's true I began this library out of frustration when I originally went from DOS/Pascal to Unix/Perl. I started polishing it again when I discovered wantarray and the fact I could initiate a hash by passing it an array. On the one hand typing my %hash = file2hash($file) is very satisfying but on the other, testing (defined wantarray) to return a scalar is truly disgusting to anyone that's ever tried to learn PERL by reading it.

As for the guides a fairly representative one is at https://perlmaven.com/open-to-read-and-write . As you can see seek and truncate are requirements in that use case but it doesn't go on to explain if you can replicate the effect of opening a+ by not doing them (or why you would die with a message about mailboxes but I digress :)

In any case the replies have somewhat illuminated the case for these weird file modes so I've made them optional parameters to the write_open sub which seems preferable to writing multiple routines.


In reply to Re^2: What is the point of a+ and w+ when opening files? by Maelstrom
in thread What is the point of a+ and w+ when opening files? by Maelstrom

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.