I have a Perl script processing a pipe. At some point, I would like the script to pause and ask for user keyboard input. my $input = <STDIN>;
does not work. It just reads next line from the pipe. How can I make Perl use different handles for pipe input and keyboard input?
相关问题
- $ENV{$variable} in perl
- Is it possible to pass command-line arguments to @
- Jasper: error opening input stream from url
- Redirecting STDOUT and STDERR to a file, except fo
- is it normal for image inputs to be omitted from t
相关文章
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Show a different value from an input that what wil
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- Is there a way to hide the new HTML5 spinbox contr
- Can NOT List directory including space using Perl
- Extracting columns from text file using Perl one-l
- Problem with piping commands in C
If you are on a Unix platform, you can open a filehandle to
/dev/tty
(or useIO::Pty
).A good example of working with tty is in "Testing Whether a Program Is Running Interactively" example here: http://pleac.sourceforge.net/pleac_perl/userinterfaces.html
You should also consider doing password IO via
Term::ReadKey
(described in perlfaq8) - I think it may be tied to TTY instead of STDIO but am not sure. If it isn't, use the TTY+Term::ReadKey solution listed at the end of this SO answer by brian d foy.Here's an example.
It's not the best style (doesn't use 3-arg form of
open
, nor uses lexical filehandles) but it should work.