Subject: | Term::ReadKey does not work on dupped handles in Windows |
This works:
type CHANGES | perl -e "BEGIN{open($PIPE, '<&=', 'STDIN' ) or die $!; close(STDIN); open(STDIN, '<', 'CON')} print uc(<STDIN>),qq(\n\n); while(<$PIPE>){s/e/EEEE/g; print}" | more
This fails spectacularly:
type CHANGES | perl -MTerm::ReadKey; -e "BEGIN{open($PIPE, '<&=', 'STDIN' ) or die $!; close(STDIN); open(STDIN, '<', 'CON')} ReadMode(3); $prefix=ReadKey(); while(<$PIPE>){s/e/EEEE/g; print $prefix,$_}" | more
SetConsoleMode failed, LastError=|5| at C:/Strawberry/perl/vendor/lib/Term/ReadKey.pm line 346.
The process tried to write to a nonexistent pipe.