Hi,
I have a text database in the following format:
where all five are tab-delimited. I am trying to read this into a hash of arrays, so that "id" is the key and an array consisting of fields 1 to 4 is the value for each row in my flat file. What I basically need to do, is given an id, is return the array items associated to it, so I can print out something like:
where the things in quotes would be actual values pulled from the flat file.
Is this possible? I have tried doing something like this:
which doesn't work... or perhaps a hash of hashes would be more suitable?
Any help gratefully received
I have a text database in the following format:
Code:
id uid short_name desc org
where all five are tab-delimited. I am trying to read this into a hash of arrays, so that "id" is the key and an array consisting of fields 1 to 4 is the value for each row in my flat file. What I basically need to do, is given an id, is return the array items associated to it, so I can print out something like:
Code:
Protein ID is "id"
UID: "uid"
Short name: "short"
Description: "desc"
Organism: "org"
where the things in quotes would be actual values pulled from the flat file.
Is this possible? I have tried doing something like this:
Code:
open (DESCS, "ids_descriptions.txt") || die ("Could not open input file!");
while( <DESCS> ) {
chomp;
($id, $uid, $short, $desc, $org) = split('\t');
$HoA{$id}=($uid, $short, $desc, $org);
}
which doesn't work... or perhaps a hash of hashes would be more suitable?
Any help gratefully received