Your task can be more easily handled by using a hash rather than an array. When you say that the data is in an tab-separated array, do you mean that you have a file which consists of tab-separated lines containing the data? Since you only want to keep one entry for each ID, then a hash containing a reference to an array holding the organism and number values will be a good way to go. Do you have any code we can help you with? Check out the
Tutorials section if you need to read up on the data types.
Update: A skeleton which will read in your data line by line...
#!/usr/bin/perl
use warnings;
use strict;
my %proteins;
while (my $line = <DATA>) {
chomp $line;
my ($pro, $org, $value) = split '\s+, $line; # \s+ : one or more wh
+itespace chars
}
__DATA__
protein1 organism1 0.843534
protein2 organism2 2.45
protein3 organism3 9.5322
protein4 organism4 0.3475474
protein1 organism6 9.4534
protein2 organism7 0.43534
protein2 organism8 1.2434
protein3 organism9 0.000003
protein3 orgnanism10 1.23325
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.