in reply to Re: STDIN schizofrenia
in thread STDIN schizofrenia

You can read from STDERR. It's just as easy as <STDERR>.
Really?
$ perl -wle 'print while <STDERR>' Filehandle STDERR opened only for output at -e line 1. $

How do you plan to read from STDERR, and how do you tell your terminal that what you type should be connected the the STDERR of the foreground job?

Abigail

Replies are listed 'Best First'.
Re: Re: STDIN schizofrenia
by etcshadow (Priest) on Oct 13, 2003 at 16:05 UTC
    ACK! My bad for posting untested code. You have to dupe STDERR to pull this off:
    open STDERRIN,"<&STDERR" or die "Could not dupe STDERR for input: $!\n +"; my $line = <STDERRIN>;
    While STDERR is a file-descriptor to your terminal (if you haven't redirected stdout), it is only an outbound channel... so you need to open an inbound channel to the same device if you want to read from it.

    ------------
    :Wq
    Not an editor command: Wq
      $ perl -wle 'open STDERRIN,"<&STDERR" or die $!; my $line = <STDERRIN> +' Filehandle STDERRIN opened only for output at -e line 1. $

      Abigail

        [me@host scratch]$ perl -wle 'open STDERRIN,"<&STDERR" or die $!; my +$line = <STDERRIN>; print "YAY!!! $line";' sadf YAY!!! sadf [me@host scratch]$
        WTF? perl version maybe?
        [me@host scratch]$ perl -v This is perl, version 5.005_03 built for i386-linux ...
        I also don't get the warning you posted when running your earlier one-liner.

        ------------
        :Wq
        Not an editor command: Wq