If you show the code what you have tried, it could be more useful to analyze and give the suggestions on this.
k_manimuthu
Junior Poster in Training
93 posts since Jun 2009
Reputation Points: 55
Solved Threads: 24
The pending method gives you the number of items in the queue, so you can peek at each of them in a loop.
#!/usr/bin/perl
use strict;
use warnings;
use Thread::Queue;
my $q = new Thread::Queue;
$q->enqueue('item1', 'item2', 'item3');
my $count = $q->pending;
my @queued_items;
push @queued_items, $q->peek($_) foreach(0 .. $count-1);
print "Items currently in queue:\n";
print join "\n", @queued_items;
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159
You're welcome. Technically, you might get away with
print join "\n", @{$q}; #Not recommended. I'm not sure why this works (for me).
but it's safer to use one of the object's methods instead of figuring out the internal structure of the object, which may vary depending on the version of the Thread::Queue module.
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159