in reply to An introduction to POE
hrmm... your script fails horribly for me. It freezes after I type the first character. The 'Type fast:' prompt is also right-flushed on my terminal. Uncommenting your cygwin line fixes the right-flushed text, but that is a bad way to do it. $/ is best kept at "\n". Try using \015\012 instead of \r\n as well. "\r\n" and "\015\012" are not guaranteed to be the same value. So to beat the snot out of POE for once (and most likely only time) in my life heh:
#!/usr/bin/perl -w $|++; use strict; my ($input, $failed); STARTIT: eval { local $SIG{ALRM} = sub { die "timed out\n" }; print 'You have 10 seconds. Type fast: '; alarm 10; chomp( $input = <STDIN> ); alarm 0; }; if ($@) { if ($@ eq "timed out\n") { if (++$failed == 3) { print "\nTimed out 3 times. You're toast!\n\n" and exit; } else { print "\nTimed out. Try again!\n\n"; } } else { die "Unhandled error: $@"; } } else { print "You said '$input'. 10 more seconds now!\n\n"; } goto STARTIT;
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: An introduction to POE
by RMGir (Prior) on Aug 10, 2003 at 12:59 UTC | |
by rob_au (Abbot) on Aug 10, 2003 at 13:23 UTC | |
by RMGir (Prior) on Aug 10, 2003 at 13:48 UTC | |
by tye (Sage) on Aug 11, 2003 at 07:14 UTC | |
by Anonymous Monk on Jan 13, 2010 at 05:32 UTC | |
| |
by rcaputo (Chaplain) on Aug 28, 2003 at 06:09 UTC | |
by RMGir (Prior) on Aug 28, 2003 at 12:04 UTC |