in reply to Re^2: How to create a two dimensional queue in Perl
in thread How to create a two dimensional queue in Perl

Ah, that makes sense.

How to "dimensionalize" your queue greatly depends on how the queue is implemented.

A simple queue can be a normal array -- that is to say, an array of scalars:

#!/usr/bin/perl -w use strict; my @MyQueue = (); { # Add items to queue push @MyQueue, 'First Entry'; push @MyQueue, 'Second Entry'; # Consume from queue (FIFO) my $nextEntry = shift @MyQueue; }

To dimensionalize this, you could make each entry in the queue an array instead of a scalar -- look up "Array Of Arrays" or AoA. Thought I saw links already embedded in other answers on this thread.

If the queue is a hash instead of an array, syntax for use of the queue is simpler, but now you have to manage the hash keys to ensure uniqueness and sequence (presumably FIFO).

I suppose you could just use a two-dimensional array, but I think doing so you'd lose the very attractive simplicity of push/shift. I'd probably just use a hash at that point.

If I had the privilege of building the two-dimensional queue manager from scratch, the question I'd find most pertinent is whether or not the calling program would benefit from receiving its state steps in an array.

If yes, I'd do the extra work to use AoA.
If no, I'd go with a hash and manage the keys myself.
Reason:I find reading the hash syntax easier.
(Yes, all things considered, that's fairly arbitrary.)

Good luck!