Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Threads reinitializing the variable

by rjt (Curate)
on Aug 05, 2013 at 14:24 UTC ( [id://1047915]=note: print w/replies, xml ) Need Help??


in reply to Threads reinitializing the variable

This will output Total count : 5, because you only increment $total_count by one on each iteration. You probably want $total_count += $ret instead (or $total_count += $t->join, if you won't be using the return value for anything else, i.e.):

$total_count += $_->join for threads->list; print "Total count : $total_count \n"; __END__ Total count : 15
use strict; use warnings; omitted for brevity.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2024-04-23 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found