nysus has asked for the wisdom of the Perl Monks concerning the following question:

I'm keying information into a custom Perl program with my left hand only and would like to use the space bar to terminate a command instead of the return key. Any IO modules out there that would facilitate this? Thanks.

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

  • Comment on Using spacebar instead of return key for terminal input

Replies are listed 'Best First'.
Re: Using spacebar instead of return key for terminal input
by tybalt89 (Monsignor) on Mar 04, 2018 at 21:35 UTC

    Term::ReadKey

Re: Using spacebar instead of return key for terminal input
by BrowserUk (Patriarch) on Mar 04, 2018 at 21:35 UTC

    Term::ReadKey


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
Re: Using spacebar instead of return key for terminal input
by davido (Cardinal) on Mar 05, 2018 at 14:33 UTC

    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

      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

Re: Using spacebar instead of return key for terminal input
by hippo (Archbishop) on Mar 05, 2018 at 14:56 UTC

    Non-perl solution:

    xmodmap -e 'keycode 0x41 = Return'

    Dononeofyourcommandshaveanyspacesinthemthen?