Re truncate (at Re: How to chomp the last new line character from the file & Re: How to chomp the last new line character from the file): note that the relevant file MUST be writable.

If you take the truncate doc (which doesn't mention my boldfaced qualifier above) as a complete and accurate statement, you'll miss something: the file in FILEHANDLE or EXPR must be writable. truncate will fail or appear to fail without explanation if the file is, for example, flocked by another process, such as an editor -- or if FILEHANDLE or EXPR is opened for reading only (eg, open ($fh, '<', "EXPR") ....

BrowserUk deserves credit here for observing that Perl's truncate may well be merely "a flimsy wrapper around the POSIX call of the same name" and for referring me to http://linux.die.net/man/2/truncate, q.v., for


In reply to Re: How to chomp the last new line character from the file by ww
in thread How to chomp the last new line character from the file by jojojo

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.