in reply to Input problem with Enter key...
in thread Input problem with Enter key...

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

Replies are listed 'Best First'.
Input problem with Enter key...
by PriNet (Monk) on Nov 07, 2016 at 02:06 UTC
    *heh* actually, those are the only lines in the script that i posted... do i need to add a
    $/=undef;
    or
    $/=chr(13);
    or
    $/="\n";
    ?

    I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...