in reply to Re^4: Problem with Windows Console input
in thread Problem with Windows Console input
re-opening STDIN doesn’t solve anshulzunke’s problem:
His problem is that my $StdIn = Win32::Console->new(STD_INPUT_HANDLE); doesn't get a handle to the console input buffer; it get's the handle to it. Thus, as you've correctly surmised, letting it go out of scope means it get closed automatically.
And note. The console input buffer is not the same thing as STDIN. Thought they are normally connected, they are not synonymous. Windows processes can have multiple input buffers; but only one of them can be associated with the console (and thus STDIN) at a time.
One simple solution would be to obtain the handle at the top level scope of the program -- it is a global resource -- and pass that handle into the subroutines.
A perhaps simpler -- and definitely more portable if that is in any way a concern -- solution would be to use Term::ReadKey with ReadMode 2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Problem with Windows Console input
by Athanasius (Archbishop) on Feb 25, 2014 at 03:56 UTC |