Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:56:28+00:00 2026-05-27T22:56:28+00:00

I am somewhat a beginner at Perl (compared to people here). I know enough

  • 0

I am somewhat a beginner at Perl (compared to people here). I know enough to be able to write programs to do many things with through the command prompt. At one point, I decided to write a command prompt game that constructed a maze and let me solve it. Besides quality graphics, the only thing that it was missing was the ability for me to use the WASD controls without pressing enter after every move I made in the maze.

To make my game work, I want to be able to have Perl take a single character as input from STDIN, without requiring me to use something to separate my input, like the default \n. How would I accomplish this?

I have tried searching for a simple answer online and in a book that I have, but I didn’t seem to find anything. I tried setting $/="", but that seemed to bypass all input. I think that there may be a really simple answer to my question, but I am also afraid that it might be impossible.

Also, does $/="" actually bypass input, or does it take input so quickly that it assumes there isn’t any input if I’m not already pressing the key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:56:29+00:00Added an answer on May 27, 2026 at 10:56 pm

    IO::Prompt can be used:

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    use IO::Prompt;
    
    my $key = prompt '', -1;
    print "\nPressed key: $key\n";
    

    Relevant excerpt from perldoc -v '$/' related to setting $/ = '':

    The input record separator, newline by default. This influences Perl’s
    idea of what a “line” is. Works like awk’s RS variable, including
    treating empty lines as a terminator if set to the null string (an empty line cannot contain any spaces or tabs).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

friends. I know, there are many questions here already on these iterators. I've read
Somewhat inexperienced programmer here trying to write a program to log into my courses
Somewhat to my surprise, the following code prints out Close twice. Running through the
somewhat open ended question here as I am mostly looking for opinions. I am
Somewhat misleading title, I know. Never actually wanted to store TimeZoneInfo object themselves: rather,
Somewhat new to jQuery, so excuse the attempt at properly identifying things. I need
I'm new to multithreading (and a somewhat beginner / intermediate programmer), and so I
Apologies for the big block 'o' text, but I'm somewhat of a beginner having
I'm somewhat of a Rails beginner, and can't shake the feeling that I'm overlooking
Somewhat of a follow-on question from here: Is there a NO-OP tag in HTML?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.