in reply to Sharing a filehandle with an asynchronous event

Here's a bit more of a simple example that uses a file handle directly, as opposed to having it hidden in the log object:

use warnings; use strict; use Async::Event::Interval; open my $fh, '>', 'test.log' or die $!; my $count = 1; my $e = Async::Event::Interval->new( 1, sub { print $fh "in event: $count\n"; $count++; } ); $e->start; for (0..3){ print $fh "write to file in main\n"; sleep 1; } $e->stop;