title: Read single characters, and use Return as EOL instead of Ctrl-D in Linux
body: <p>I'm a beginner to perl, and just started reading user input in my script.</p>
  
  <pre><code>chomp(my $inp = &lt;&gt; );
  </code></pre>
  
  <p>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.</p>
  
  <p>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 <code>getch</code>. In Bash, I'd use a <code>read</code> and <code>$REPLY</code>.</p>
  
  <p>I'd also like to know how to use the Return key to terminate user input.</p>
  
  <p>For getting single characters, <a href="http://perldoc.perl.org/functions/getc.html" rel="nofollow">perldoc mentions</a>:</p>
  
  <pre><code>if ($BSD_STYLE) {
          system "stty cbreak &lt;/dev/tty &gt;/dev/tty 2&gt;&amp;1";
      }
      else {
          system "stty", '-icanon', 'eol', "\001";
      }
      $key = getc(STDIN);
      if ($BSD_STYLE) {
          system "stty -cbreak &lt;/dev/tty &gt;/dev/tty 2&gt;&amp;1";
      }
      else {
          system 'stty', 'icanon', 'eol', '^@'; # ASCII NUL
      }
      print "\n";
  </code></pre>
  
  <p>Surely in a language like perl, it isnt <code>that</code> difficult?</p>
  
  <p>Edit: It seems like what I was looking for isnt natively available. However, IO::Prompter seems to be the solution.</p>