Dear wise monks,
sorry if that is a stupid question but I'm a biologist rather than a coder... I want to analyze some biological data. Therefore, I need to read and analyze 4 large files before I can actually analyze my own data. To save time I would like to read the 4 files in parallel using Parallel::Forkmanager. My problem is that I have no idea (even after google search) how to return the data back to the parent. Each subroutine generates a lot of different data structures such as hashes and arrays that I need later on in the parent process. Below is the code that I currently try.
use Parallel::ForkManager;
$threads=4;
if($threads==1)
{
read_genome();
read_mapfile();
read_GTF();
read_RM();
}
else
{
@eval_code=("read_genome();","read_mapfile();","read_GTF();","read
+_RM();");
my$pm=new Parallel::ForkManager($threads);
foreach$eval_code(@eval_code)
{
$pm->start and next;
eval$eval_code;
$pm->finish;
}
$pm->wait_all_children;
}
sub read_genome
{
# do something
}
sub read_mapfile;
{
# do something
}
sub read_GTF
{
# do something
}
sub read_RM
{
# do something
}
# use data generated in the subroutines
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.