The pending method gives you the number of items in the queue, so you can peek at each of them in a loop.
my $q = new Thread::Queue;
$q->enqueue('item1', 'item2', 'item3');
my $count = $q->pending;
push @queued_items, $q->peek($_) foreach(0 .. $count-1);
print "Items currently in queue:\n";
print join "\n", @queued_items;
I was also using the pending method in my program however it was only for dequeueing items from the queue. Thanks for showing how to use it by printing the items in the queue with the help of the peek method.
I did found a way to print the items in the queue yesterday simply by using Data:: Dumper
print "Items currently in queue: ";
print Dumper $q;
However, I didn't know how to omit "bless" and 'Thread::Queue', and here was the result:
Items currently in queue: bless( ["item1","item2","item3"], 'Thread::Queue' )
Anyway, just wanted to share what I had to do to print the queued items. Thanks again! :)