use threads; use Thread::Queue; sub processEvents { my $Q = shift; while( my $event = $Q->dequeue ) { ## Process events } } my $Q = new Thread::Queue; my $thread = threads->create( \&processEvents, $Q ); $inotify->watch($watchpoint,IN_ALL_EVENTS); while ($keepOnWatching) { $Q->enqueue( $inotify->read; ) }