Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: What is the correct way to use Thread::Queue::Any ?

by fx (Pilgrim)
on Jan 07, 2004 at 17:45 UTC ( [id://319539]=note: print w/replies, xml ) Need Help??


in reply to Re: What is the correct way to use Thread::Queue::Any ?
in thread What is the correct way to use Thread::Queue::Any ?

I thought that enqueuing an undef would have stopped that while loop and hence didn't much care about how it would interact with printf.

Is the behaviour of enqueuing (or perhaps more specifically dequeuing) undef's under Thread::Queue::Any different than under Thread::Queue for some reason that I'm not thinking of?

Many thanks.

  • Comment on Re: Re: What is the correct way to use Thread::Queue::Any ?

Replies are listed 'Best First'.
Re: Re: Re: What is the correct way to use Thread::Queue::Any ?
by liz (Monsignor) on Jan 07, 2004 at 17:56 UTC
    while( my($returned_value) = $queue->dequeue ) {

    You forget that $queue->dequeue always returns an array with at least 1 element. So the condition being checked is always 1 or higher. Something like:

    while( my ($returned_value) = $queue->dequeue ) { last unless defined $returned_value;
    should do the trick, I think.

    Liz

Re: Re: Re: What is the correct way to use Thread::Queue::Any ?
by ysth (Canon) on Jan 07, 2004 at 20:03 UTC
    I thought that enqueuing an undef would have stopped that while loop
    Nope, that's a list assignment in scalar context, which evaluates to the number of items on the right of the assignment.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://319539]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-23 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found