And I have a code that take two files that ends with *R.fa and *P.fadata1R.fa data2P.fa data2R.fa data2P.fa #say each of this file contain lines of numbers .... #and there are 40 of files
So the code is like this:perl mycode.pl data1R.fa data1P.fa perl mycode.pl data2R.fa data2P.fa
How can I make my code above such that it can take all multiple files iteratively? to give output sth like this:use warnings; use strict; my $file_r = $ARGV[0]; my $file_r = $ARGV[1]; open FILE_R, "< $file_r" or die "Can't open $file_r : $!"; open FILE_P, "< $file_p" or die "Can't open $file_p : $!"; my @rdata; my @pdata; #these two are of the same size while (<FILE_R>){ chomp; push @rdata, $_; } while (<FILE_P>){ chomp; push @pdata, $_; } my @sum = map {$rdata[$_] + $pdata[$_]} 0..$#pdata; print "$file_r\n"; print ">\n"; foreach my $sum (@sum){ print "$sum\n"; }
>data1 sum_of_elements from data1R.fa and data1P.fa >data2 sum_of_elements from data2R.fa and data2P.fa
In reply to Finding Files and Processing them iteratively by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |