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.