in reply to how to use angle operator with timeout?
Try Prompt::Timeout or IO::Prompter.
The basic technique just involves the alarm function...
use 5.010; use strict; use warnings; use Try::Tiny; my $line; try { local $SIG{ALRM} = sub { die "ALARM\n" }; alarm 10; say "Please enter some text, but quick!"; $line = <>; chomp $line; alarm 0; } catch { my $e = shift; $e =~ /^ALARM/ ? warn("timeout\n") : die($e); }; say "Got: '$line'";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to use angle operator with timeout?
by BrowserUk (Patriarch) on Feb 03, 2013 at 23:55 UTC | |
by Anonymous Monk on Feb 04, 2013 at 00:50 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2013 at 01:37 UTC | |
by tmharish (Friar) on Feb 04, 2013 at 09:12 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2013 at 09:38 UTC | |
| |
by Anonymous Monk on Feb 04, 2013 at 02:39 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2013 at 09:36 UTC | |
by tobyink (Canon) on Feb 04, 2013 at 15:07 UTC | |
|
Re^2: how to use angle operator with timeout?
by Mark_Galeck (Novice) on Feb 05, 2013 at 08:19 UTC |