Perl use Return as EOL instead of Ctrl-D in Linux
I'm a beginner to perl, and just started reading user input in my script.
chomp(my $inp = <> );
I have been used to using Return key as the terminator for user input in
other languages, and am unsure how to stop reading user input after
getting a single key press, or some characters followed by Return key. In
perl running on unix, capturing input via the diamond operator, seems to
require pressing Ctrl-D for end of input.
My problem is that I'd like to build an interactive menu where user is
presented a list and asked to press "A", "B" or "C". Once he presses any
of these keys, I'd like to loop according to conditions, without waiting
for him to press Ctrl D. How can I get this level of interactive user
input in perl? In C, I'd use getch. In Bash, I'd use a read and $REPLY.
No comments:
Post a Comment