in reply to Re^2: Alarms with ActivePerl do not work properly (small modification)
in thread Alarms with ActivePerl do not work properly
The downside to your modification is that if lines come 3 per second, you still only read one per second. And if lines come one every 2 seconds, your alarm has even odds of not doing anything.
The sleep can be varied to suit. It would be better to invoke the sleep before the read.
In essence, the trick is to ensure that the read doesn't block. I've posted several other variations on the theme here over the years. Some more thorough than others.
I also think that the emulation can be fixed. Just use a select/sysread loop, ...
select doesn't work on filehandles on Win32.
In fact it is even possible to make that fix in pure Perl.
I guess that "fact" is tempered by the above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Alarms with ActivePerl do not work properly (small modification)
by tilly (Archbishop) on Jan 13, 2011 at 06:33 UTC | |
by BrowserUk (Patriarch) on Jan 13, 2011 at 07:12 UTC | |
by Corion (Patriarch) on Jan 13, 2011 at 18:01 UTC |