in reply to Using spacebar instead of return key for terminal input

Do you even need to manipulate how keys are interpreted? It sounds like you really could just modify the record separator.

local $/ = " "; # two spaces. while (my $rec = <>) { chomp($rec); foreach my $field (split /[ ]/, $rec) { # Any x20 space for field +separator, after having dealt with double-spaces. # Do something with $field } }

Single space to separate fields, double space to separate records.


Dave

Replies are listed 'Best First'.
Re^2: Using spacebar instead of return key for terminal input
by nysus (Parson) on Mar 05, 2018 at 20:56 UTC

    Interesting. I'd probably use this approach but my program limits input to certain keys to prevent mistakes.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks