Syntactic Confectionery Delight | |
PerlMonks |
Re^2: Can Perl write multiple files at the same time?by marioroy (Prior) |
on Dec 13, 2014 at 02:39 UTC ( [id://1110235]=note: print w/replies, xml ) | Need Help?? |
The MCE 1.515 was moved to back pan some time back. Here is the URL.
There is another example Re^4: Using MCE to write to multiple files.. The MCE->sendto method is available. A nice thing is that MCE caches the file handle, therefore only opening the file handle once during the run. The sendto method appends, thus the reason for unlink. Below, using the Flow model as input_data is not required to run.
Another way is via MCE->print, MCE->printf, MCE->say. MCE serializes data from workers to the manager process. The output is done by the manager process. These methods are beneficial when many workers write to same file simultaneously.
In case the reader missed it, the syntax for mce_flow requires the sub in front of the opening brace unlike mce_loop which takes a block. The reason is that mce_flow can take many anonymous blocks; e.g. mce_flow sub { ... }, sub { ... }.
In Section
Seekers of Perl Wisdom
|
|