sub worker { my $work_queue = shift; my $tid = threads->tid; local $/; WORKER: while ( !$thread_term ) { # signal to the thread poolq that we are ready to work $pool_queue->enqueue( $tid ); # wait for some filename to be put into my work queue my $file = $work_queue->dequeue; ...