Simplicity itself using [cpan://threads]. #! perl -slw use strict; use threads qw[ async ]; use Thread::Queue; my $Qin = new Thread::Queue; async { my $input; do { chomp( $input = <STDIN> ); $Qin->enqueue( $input ); } until $input =~ m[^Q(?:uit)?]i; }->detach; my %events; while( sleep 1 ) { if( $Qin->pending ) { my $input = $Qin->dequeue ; last if $input =~ m[^Q(?:uit)?]i; ## Process input print "Got: $input"; } ## process timer based stuff if( exists $events{ scalar localtime } ) { ## Processing event } }
In reply to Re: Event timing and input processing
by BrowserUk
in thread Event timing and input processing
by thekestrel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |