Does your program contain any lines that manipulate the special variable, $/?

use strict; use warnings; $/ = undef; print "Say something: " my $Input = <STDIN>; print "You typed $Input\n';

It sounds like either your script, or a module your script uses has altered $/. At least that's the first thing that jumps to mind for me. There are probably other ways to arrive at that type of behavior, but that's one of the easiest ones to arrive at.

By the way, a better way to gather user input may be found buried in the core Perl module, ExtUtils::MakeMaker:

use ExtUtils::MakeMaker q(prompt); my $input = prompt('Say something: '); print "You typed $input\n";

prompt() allows you to set a default value, and uses that default if the user hits enter without typing anything, or if it detects a non-interactive environment.


Dave


In reply to Input problem with Enter key... by davido
in thread Input problem with Enter key... by PriNet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.