Based on your previous questions1, you are probably talking about threads. As Corion pointed out, Thread::Queue provides queue functionality to threads. According to its documentation (reformatted for brevity):
Any data types supported by threads::shared can be passed via queues: a) Ordinary scalars, b) Array refs, c) Hash refs, d) Scalar refs, e) Objects based on the above. Ordinary scalars are added to queues as they are.
If not already thread-shared, the other complex data types will be cloned (recursively, if needed, …
Your question here is very vague (please read How do I post a question effectively?), but taking your meaning of "two dimensional queues" as literally as I can, I believe a simple anonymous array ref (constructed with [ ... ]) would work for you. Something like this:
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 }
That's pretty much the pattern. You should be able to easily adapt it to your needs. If not, write up a better description of what you need, and we'll help you from there.
____________
1. meena's recent threads: Create your own signal in Perl, Alarm In Perl
In reply to Re: How to create a two dimensional queue in Perl
by rjt
in thread How to create a two dimensional queue in Perl
by meena
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |