I, also, am confused about what is supposed to be summed while processing the file (I can't see anything numeric in your sample data). (Update: I also don't understand what you want to do with a 2D array, or why.) However, this code will produce exactly the output you specify from the given input. (Caution: The tabs that are supposed to be in the __DATA__ section may not survive the posting process. Check and restore them as needed.)
use strict; use warnings; <DATA>; # ignore first input line while (my $line = <DATA>) { $line =~ s{ \t }{; }xmsg; # make output ProteinName field min 4 cols wide, right justified. $line =~ s{ \A ([^;]*) (?= ;) }{ sprintf '%4s', $1 }xmse; print $line; } exit; __DATA__ ProteinName MF1 MF2 MF3 GH1 Growth factor activity Growth hormone receptor binding Ho +rmone activity POMC G protein-coupled receptor binding Hormone activity Sign +aling receptor binding THRAP3 ATP binding Source Nuclear receptor transcription coactiv +ator activity Phosphoprotein binding
Update: I just round-tripped the code posted above and it looks like the tabs in the __DATA__ section survived intact!
Give a man a fish: <%-{-{-{-<
In reply to Re: storing a file in 2d array
by AnomalousMonk
in thread storing a file in 2d array
by shabird
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |