in reply to Re: Read and analyze two file in parallel
in thread Read and analyze two file in parallel
Thanks! In the meanwhile I tried something and it worked, I post it here in case it could be helpful to someone (or in case you have suggestions to give me on it). Here it is:
sub read_file_line { my $fh = shift; if ($fh and my $line = <$fh>) { chomp $line; return [ split(/\t/, $line) ]; } return; } #sub compute { # do something with the 2 values #} open(my $f1, $input); open(my $f2, $input_1); my $pair1 = read_file_line($f1); my $pair2 = read_file_line($f2); my $value; open OUT,">$file"; while ($pair1 and $pair2) { $value=$pair1->[3]*(1-$pair2->[3]); $pair1 = read_file_line($f1); $pair2 = read_file_line($f2); print OUT $pair1->[0]."\t".$pair1->[1]."\t".$pair1->[2]."\t".$valu +e."\n"; } close($f1); close($f2); close OUT;
Thanks, Giulia
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read and analyze two file in parallel
by aaron_baugher (Curate) on Mar 14, 2012 at 22:21 UTC |