in reply to binmode for @ARGV
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:
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.use open IN=>":raw", OUT=>":raw";
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
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.*CORE::GLOBAL::open= sub { my( $fh, $arg, @args )= @_; my $ret= CORE::open( $fh, $arg, @args ); binmode( $fh ); return $ret; };
So changing
to start with justif (PL_op && PL_op->op_type == OP_OPEN) { /* set up disciplines */ U8 flags = PL_op->op_private; in_raw = (flags & OPpOPEN_IN_RAW);
might solve the problem?if (PL_op) {
I guess I'll download modern Perl source and send such a patch to p5p and see how they take it.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: binmode for @ARGV (open.pm)
by BrowserUk (Patriarch) on Jan 30, 2003 at 22:01 UTC | |
|
Re: Re: binmode for @ARGV (open.pm)
by bsb (Priest) on May 24, 2004 at 07:56 UTC |