monkfan has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Finding Files and Processing them iteratively
by Random_Walk (Prior) on Feb 25, 2005 at 11:28 UTC | |
by monkfan (Curate) on Feb 25, 2005 at 13:53 UTC | |
Re: Finding Files and Processing them iteratively
by deibyz (Hermit) on Feb 25, 2005 at 12:30 UTC | |
Re: Finding Files and Processing them iteratively
by virtualsue (Vicar) on Feb 25, 2005 at 12:45 UTC | |
Re: Finding Files and Processing them iteratively
by rupesh (Hermit) on Feb 25, 2005 at 12:40 UTC | |
by satchm0h (Beadle) on Feb 25, 2005 at 13:24 UTC | |
Re: Finding Files and Processing them iteratively
by blazar (Canon) on Feb 25, 2005 at 13:02 UTC |