Hi all, I am new to Perl. I searched around for a fix to my issue but could not find it. I am using the win32.pm in order to read single keystroke input to move a cursor around a console screen and it works great. However, I also need to read a line of input for the player name. STDIN seems to hang when I use the Win32.pm though it does not error nor does it respond any longer once I try to use it and I have to break out of the program. Here is my code.
#!/usr/bin/perl require Term::Screen::Win32; #This pm is used for single key input, specific screen location # and other screen manipulations (clrscr() clears screen) $scr = new Term::Screen::Win32; #This sets up $scr with the screen acc +ess commands using Win32.pm unless ($scr) { die " Something's wrong \n"; } $scr->clrscr(); while (length($ans)<9) { $scr->at(0,0); print "Type something here: \n"; $ans = $scr->getch(); if ($ans =~ "\r") {print"True";} $newval .= $ans; $scr->at(1, 0); print $newval; }#end while $scr->at(2,0); print "Enter something: "; $response = <stdin>; print $response,"\n";
What I want, is to be able to read a single keypress to move the cursor around the screen and also be able to input a name/word. I have also tried saving the continuous key input but checking for \r doesn't seem to work unless the Win32.pm echo() is used. So with echo(), there may be a way to get a full line of text rather than just a single character. I am still tinkering. Any thoughts or advice would be appreciated.

In reply to win32.pm disabling stdin? by LostUser

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.