Thanks for your advice !

It's interesting that binmode() only disables the :crlf layer but doesn't remove it. (Just discovered, that's actually documented in PerlIO.)

Does it still interfere with tell() even when it's disabled ? (perlport says: "If you use binmode on a file, however, you can usually seek and tell with arbitrary values in safety.")

I'm just curious, what happens if you try these on Windows:

open $fh, "<", $^X or die; binmode $fh, ":raw"; # perldoc says: identical to 'binmode $fh' print "3: ", join(' ', PerlIO::get_layers($fh, details => 1)), "\n"; close $fh; open $fh, "<", $^X or die; binmode $fh, ":raw:perlio"; # seems not useful (see below) print "4: ", join(' ', PerlIO::get_layers($fh, details => 1)), "\n"; close $fh;

On UNIX that gives:

3: unix 4195328 perlio 4195328 4: unix 4195328 perlio 4195328 perlio 4195328

I know this discussion should probably go into a Perl develompent group but let me just explain where I'm having problems to understand things here:

If one has to use open($fh, '<:raw:perlio', $file) to get a clean and buffered binary stream this unconditionally forces a :perlio layer onto the stack, which in turn inserts a :unix layer below it.

Now, what about MacOS where Perl uses :stdio by default ? (I know far too little about MacOS but it must be faster than :unix:perlio there.) Also if someone wants to change the default layers via the PERLIO environment variable (for whatever reason), it would be blithely ignored on those streams.


In reply to Re^3: Using ":raw" layer in open() vs. calling binmode() by Anonymous Monk
in thread Using ":raw" layer in open() vs. calling binmode() by Anonymous Monk

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.