use Thread::Queue; my $q = Thread::Queue->new; # Later, in producer thread(s) ($first and $second # represent the 2 dimensional tuple you wish to enqueue) $q->enqueue( [ $first, $second ] ); # Anonymous array ref # Later still, to signal the end of all elements: $q->enqueue(undef); # In the consumer thread(s): while (defined (my $ref = $q->dequeue)) { my ($first, $second) = @$ref; # Dereference array # ... Process $first and $second }