LostUser has asked for the wisdom of the Perl Monks concerning the following question:
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.#!/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";
|
|---|