I'm a little new to Perl (compared to the people here). I know enough to be able to write programs for many tasks using the command line. At some point, I decided to write a command line game that built a maze and allowed me to solve it. In addition to high-quality graphics, the only thing that was missing was the ability to use WASD controls without pressing the enter button after each step that I made in the maze.
For my game to work, I want Perl to use a single character as input from STDIN, without requiring me to use something to separate the input, for example, the default \n . How would I do that?
I tried to find a simple answer on the Internet and in the book that I have, but I didn't seem to find anything. I tried setting $/="" but it seems to have bypassed all the input. I think there may be a very simple answer to my question, but I also fear that this may not be possible.
Also, does $/="" really bypass the input, or does it accept the input so quickly that it assumes there is no input if I haven't pressed a key yet?
source share