You could also use threads and threads:shared to avoid the forks and pipes.
#!/usr/bin/perl use warnings; use strict; use Glib; my $main_loop = Glib::MainLoop->new; my @input = ('a'..'z'); my $count = 1; my $timer = Glib::Timeout->add (1000, \&timer_callback, undef, 1 ); sub timer_callback{ $count++; print "$count\n"; return 1; } my $timer1 = Glib::Timeout->add (100, \&timer1_callback, undef, 1 ); sub timer1_callback{ push (@input,shift(@input)); # circular list print "\t", $input[0], "\n"; return 1; } Glib::IO->add_watch (fileno 'STDIN', [qw/in/], \&watch_callback, 'STDI +N'); $main_loop->run; #################################################################### sub watch_callback { my ($fd, $condition, $fh) = @_; if(sysread(STDIN, my $buf, 1024)){ print "$buf\n" } #always return TRUE to continue the callback return 1; }
In reply to Re: outline of POE setup for responding to stdin and timer
by zentara
in thread outline of POE setup for responding to stdin and timer
by bchoward00
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |