eliminate tickets on older versions
[andk-cpan-tools.git] / bin / eg-readline-01.pl
blob26aebabc800a9de91151017a71527cd8fd1fb8e5
1 # currently works neither with perl-5.8.0@29163 nor 29243 but has
2 # worked recently
4 # Now, after a 'stty sane' again works with 29163 and 29243
6 use strict;
8 use AnyEvent;
10 my $cv = AnyEvent->condvar;
12 my $io_watcher = AnyEvent->io (fh => \*STDIN,
13 poll => 'r',
14 cb => sub {
15 warn "io event <$_[0]>\n"; # will always output <r>
16 chomp (my $input = <STDIN>); # read a line
17 warn "read: $input\n"; # output what has been read
18 $cv->broadcast if $input =~ /^q/i; # quit program if /^q/i
19 });
21 my $time_watcher; # can only be used once
23 sub new_timer {
24 $time_watcher = AnyEvent->timer (after => 2,
25 cb => sub {
26 warn "timeout\n"; # print 'timeout' about every second
27 &new_timer; # and restart the time
28 });
31 new_timer; # create first timer
33 $cv->wait; # wait until user enters /^q/i