Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^5: Threading with a twistby Random_Walk (Prior) |
on Oct 04, 2017 at 07:23 UTC ( [id://1200645]=note: print w/replies, xml ) | Need Help?? |
We could reduce your question to: Why does using subroutines make code simple? We are looking at two very different functions. It is logical to split them and keep two simple easy to debug blocks, rather than interleave them in a complex routine. Depending on the simplicity of the records going to <STDOUT> it may even be better to have the workers print directly. If the records are long and will not print as an atomic operation, or if there is post processing, then an publishing thread that gathers them and prints them keeps this work in one place. Something like this looks very simple to me.
Do you have an example where you read <STDIN> and the $result queue in the same code block, that is simpler? Now if we need to add pre or post processing then it sits nicely in the dispatcher or publisher routine without being all mixed up. Cheers,
Pereant, qui ante nos nostra dixerunt!
In Section
Seekers of Perl Wisdom
|
|