in reply to Reaped: count total number of occurrence in all files
As you do not ask for something nor point to particular errors i can only guess:
first i cannot understand how your data sample can be splitted using \t\s pattern (ah ok you are setting $/ for this..).
second i do not see where you are opening files (maybe the script is run under -nl ?)
If each file just contains 2 lines you can simply do:
my $key = <$filehandle>; # first line my $value = <$filehandle>; # second line
You also have no need to iterate over an array to get the count: @array in scalar context returns the numbers of elements. Also $#array contains the index of the last element ( so $#array + 1 == scalar @array ).
You also want the name of the file to be preserved somehow: you can read about $ARGV or you must create a sub that given the filename as arg, open it process it and store the filename along results.
A pray to you and to ALL BIONFORMATICS here around: sample data can be AGATC instead of a line of hundreds of chars? have readable data as sample help my eyes a lot!
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: count total number of occurrence in all files
by Eily (Monsignor) on May 09, 2016 at 09:35 UTC | |
by Discipulus (Canon) on May 09, 2016 at 10:00 UTC | |
|
Re^2: count total number of occurrence in all files
by AnomalousMonk (Archbishop) on May 09, 2016 at 13:08 UTC |