Capturing input from the keyboard 
Author Message
 Capturing input from the keyboard

Sure it sounds simple, but I'm not familiar with perl.  I want to quiz
people on adding signed integers.  I know how to randomly generate numbers
but how do I wait for a keyboard response, capture the input, and test it
for correctness.

I have Perl In a Nutshell by O'Reilly but something tells me I should have
bought Perl for Dummies.

:-)

If you check comp.lang.perl.tk, I have been unsuccessfully experimenting
with the Tk module.  I'd rather stick to the basics if it's possible.  Your
knowledge and advice will be appreciated.  Thanks

--
                    The Liberator


Web Site: http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 Capturing input from the keyboard
Try:
  use strict;

  print "Please enter a number: ";
  chomp(my $user_num = <STDIN>);

Then manipulate $user_num as you wish

 -- Robert Watkins

Quote:

> Sure it sounds simple, but I'm not familiar with perl.  I want to quiz
> people on adding signed integers.  I know how to randomly generate numbers
> but how do I wait for a keyboard response, capture the input, and test it
> for correctness.

> I have Perl In a Nutshell by O'Reilly but something tells me I should have
> bought Perl for Dummies.

> :-)

> If you check comp.lang.perl.tk, I have been unsuccessfully experimenting
> with the Tk module.  I'd rather stick to the basics if it's possible.  Your
> knowledge and advice will be appreciated.  Thanks

> --
>                     The Liberator


> Web Site: http://www.liberator.net/



Wed, 18 Jun 1902 08:00:00 GMT  
 Capturing input from the keyboard
Robert:

The system doesn't wait for a response.  It blows right threw it as if I
never inputted anything.

--
                    The Liberator


Web Site: http://www.liberator.net/


Try:
  use strict;

  print "Please enter a number: ";
  chomp(my $user_num = <STDIN>);

Then manipulate $user_num as you wish

 -- Robert Watkins

Quote:

> Sure it sounds simple, but I'm not familiar with perl.  I want to quiz
> people on adding signed integers.  I know how to randomly generate numbers
> but how do I wait for a keyboard response, capture the input, and test it
> for correctness.

> I have Perl In a Nutshell by O'Reilly but something tells me I should have
> bought Perl for Dummies.

> :-)

> If you check comp.lang.perl.tk, I have been unsuccessfully experimenting
> with the Tk module.  I'd rather stick to the basics if it's possible.
Your
> knowledge and advice will be appreciated.  Thanks

> --
>                     The Liberator


> Web Site: http://www.liberator.net/



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Capture the keyboard arrows action

2. keyboard input without CR, CTRL-D

3. keyboard input without CR, CTRL-D problem..

4. Keyboard Input

5. How to do unbuffered keyboard input?

6. raw input (keyboard) in msdos-perl?

7. convert keyboard input into morsecode

8. Questions about unbuffered keyboard input

9. using getc to input user response from keyboard

10. PerlCRT.dll (was Reading keyboard Input

11. Reading keyboard input

12. keyboard input without carriage return

 

 
Powered by phpBB® Forum Software