in reply to Reoccuring time based event inside a loop
It's easy and safe with threads.
#! perl -slw use strict; use threads qw[ async ]; use threads::shared; $| = 1; ## Simulate tail open FILE, q[ perl -le"$|=1; print and select(undef,undef,undef,.1) for 1 .. 30" + | ] or die $!; my $done : shared = 0; my $t = async { while( !$done and sleep 1 ) { print 'Blah'; } }; while( <FILE> ) { printf; } $done = 1; $t->join; __END__ P:\test>397046 1 2 3 4 5 6 7 8 9 10 Blah 11 12 13 14 15 16 17 18 19 Blah 20 21 22 23 24 25 26 27 28 Blah 29 30 Blah P:\test>
|
|---|