I updated your code to the following, and added the output I got as comments after every command (Win 10, Perl 5.28).

@echo off set PERLIO= perl -E "print STDERR PerlIO::get_layers(STDOUT),qq(\n); print qq(\n)" + >> tmp REM unixcrlf 0d0a perl -E "binmode STDOUT; print STDERR PerlIO::get_layers(STDOUT),qq(\n +); print qq(\n)" >> tmp REM unixcrlf 0a set PERLIO=:raw perl -E "print STDERR PerlIO::get_layers(STDOUT),qq(\n); print qq(\n)" + >> tmp REM unix 0d0a perl -E "binmode STDOUT; print STDERR PerlIO::get_layers(STDOUT),qq(\n +); print qq(\n)" >> tmp REM unix 0d0a perl -E "binmode STDOUT, ':crlf'; print STDERR PerlIO::get_layers(STDO +UT),qq(\n); print qq(\n)" >> tmp REM unixcrlf 0d0d0a set PERLIO=:raw:crlf:pop perl -E "print STDERR PerlIO::get_layers(STDOUT),qq(\n); print qq(\n)" + >> tmp REM unix 0a perl -E "binmode STDOUT; print STDERR PerlIO::get_layers(STDOUT),qq(\n +); print qq(\n)" >> tmp REM unix 0a perl -E "binmode STDOUT, ':crlf'; print STDERR PerlIO::get_layers(STDO +UT),qq(\n); print qq(\n)" >> tmp REM unixcrlf 0d0a set PERLIO= perl -Mopen=IO,raw -E "say unpack 'H*', $_ while <ARGV>" tmp del tmp

In a bug I reported a while back, I got this explanation in regards to the :crlf layer on Windows:

:crlf is not just a translation layer on top of the buffering system, it's an alternative buffering system that will optionally do the translation. Calling binmode will disable that translation but not the layer. For extra confusion, on Linux binmode will pop off the crlf layer, because it's not presumed to be the only buffering layer.

What I think this means is that anytime the :crlf layer is missing on Windows, the behavior may be wonky. This appears to be triggered by PERLIO=:raw, and may very well be a bug. Is there any way you can avoid that environment variable being set and only use binmode?


In reply to Re: Perl seems to mistreat "PerlIO" environment variable (Windows) by haukex
in thread Perl seems to mistreat "PerlIO" environment variable (Windows) by vr

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.