Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Giving up on user input - keyboard timeout in Perl

There's an old piece of code that I've used to demontstrate how (in Perl) you can prompt for a user input ... but then time out the input on an alarm signal if the user doesn't enter data within a certain time. The code's [here] if you want to have a look. But let me warn you ... it's one of those thisng that may be somewhat operating system dependent, even though most Perl code is pretty darned portable.
A correspondent writes: "try the code; it hangs after the first warning. The comeon signal handler needs to call the alarm and increment the counter because the code in the main loop that looks to do so is never reached when no entry is typed. a correction would look like [this] (good exercise for student, by the way, so thanks)"

Hmmm ... on the laptops that I'm working on today (Mac OS X / Perl 5.8.x) both versions work perfectly. The second version (from M.K.) illustrates his point, but with a degree of code duplication so it could really do with being tidied up ... and I have not yet tested it across a range of platforms. I'm posting links to both examples, and these notes, because waiting for a user input ... but only for a while, before carrying on ... is a very useful capability, and these notes may be of some help to the reader, even though I have not fully researched the story.

What is does remind me of is that saying:
"Compatible" = "99% Compatible" = "Incompatible"

and the need to check and recheck code across platforms, and HTML and JavaScript across browsers!
(written 2009-08-28)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P305 - Perl - User Input
  [2876] Different perl examples - some corners I rarely explore - (2010-07-18)
  [2213] Keyboard reading in Perl - character by character not line by line - (2009-06-01)


Back to
Checking the database connection manually
Previous and next
or
Horse's mouth home
Forward to
Lua Regular Expressions
Some other Articles
Computing under the influence of alcohol
Reading all our recent news from a single source
Looking ahead to the Autumn season of training and accommodation
Lua Regular Expressions
Giving up on user input - keyboard timeout in Perl
Checking the database connection manually
Object Oriented programming - a practical design example
Making variables persistant, pretending a database is a variable and other Perl tricks
Handling XML in Perl - introduction and early examples
Wiltshire / Melksham Weddings - guest accommodation
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2382_Giv ... -Perl.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat