I checked back to see if anyone had yet looked up how to do this. Since noone had, I hit binmode which pointed me to perldoc open which suggests:

use open IN=>":raw", OUT=>":raw";
but it doesn't work because the calls to open() that are done by <> don't occur in the lexical context of the use open and so are not affected by it? That sucks.

This problem (binmode with <>) has been known for years and I recall solutions being discussed years ago so I was quite disappointed to not find the solution. Perhaps open.pm was the solution and then it was "fixed" to be lexically scoped which also made it useless for its original purpose? (probably not)

Even

*CORE::GLOBAL::open= sub { my( $fh, $arg, @args )= @_; my $ret= CORE::open( $fh, $arg, @args ); binmode( $fh ); return $ret; };
doesn't work because <> calls some C code directly rather than acting like call to open from Perl code. It calls Perl_do_open() which calls Perl_do_open9() which does check the flags set by open.pm. But it only checks the flags if it was called via an OP_OPEN opcode.

So changing

if (PL_op && PL_op->op_type == OP_OPEN) { /* set up disciplines */ U8 flags = PL_op->op_private; in_raw = (flags & OPpOPEN_IN_RAW);
to start with just
if (PL_op) {
might solve the problem?

I guess I'll download modern Perl source and send such a patch to p5p and see how they take it.

                - tye

In reply to Re: binmode for @ARGV (open.pm) by tye
in thread binmode for @ARGV by BrowserUk

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.