in reply to Re: Re: STDIN schizofrenia
in thread STDIN schizofrenia

Seems to be version dependent:
#!/usr/bin/perl use strict; use warnings; no warnings qw /syntax/; my $program = 'open STDERRIN, "<&STDERR" or die $!; my $line = <STDERRIN>; print "YAY!!! $line";'; foreach my $version (qw /5.005 5.6.0 5.6.1 5.8.0 5.8.1/) { print "Version $version\n"; system "/opt/perl/$version/bin/perl -we '$program'"; } __END__ Version 5.005 foo YAY!!! foo Version 5.6.0 bar YAY!!! bar Version 5.6.1 Filehandle STDERRIN opened only for output at -e line 2. baz YAY!!! baz Version 5.8.0 Filehandle STDERRIN opened only for output at -e line 2. Use of uninitialized value in concatenation (.) or string at -e line 2 +. YAY!!! Version 5.8.1 Filehandle STDERRIN opened only for output at -e line 2. Use of uninitialized value in concatenation (.) or string at -e line 2 +. YAY!!!

It runs on 5.005, 5.6.0 and 5.6.1, although it gives a warning under 5.6.1. It won't read from STDERRIN in 5.8.0 or 5.8.1.

Abigail

Replies are listed 'Best First'.
Re: Re: STDIN schizofrenia
by etcshadow (Priest) on Oct 13, 2003 at 22:51 UTC
    Cool. Well, the better way is to try to open /dev/tty, anyway (which I referenced in the original post, too). I was just going off of "use STDERR as a reference to the controlling terminal" notion that is used in many tools... like vim, for example, when you pipe the file to edit in off of STDIN.
    [me@host scratch]$ ptyexec man vim | grep stdin - The file to edit is read from stdin. Commands are +read from stderr, which should be a tty. [me@host scratch]$

    ------------
    :Wq
    Not an editor command: Wq
      I've send a bugreport to p5p about this issue.

      Abigail

      To make it more confusing, dupping file descriptor 2 for read works fine, even in 5.8.x and 5.9.

      open STDERRIN, "<&2" or die $!; # Works. open STDERRIN, "<&STDERR" or die $!; # Does not work.

      Abigail