I am trying to load data from a flat file into a hash defined as this:
hash{key}{0} = 1st field
hash{key}{1} = 2nd field
hash{key}{2} = 3rd field
So I can retrieve it last by referencing hash{key}{0,1 or 2}
Here is what my flat file look like:
law7505-01|kas02021|Contracts 1|email1.address\@sub.domain.edu
law7505-02|lsk02002|Contracts 2|email2.address\@sub.domain.edu
.etc.
Here is my current code:
while (<IFH>) {
chomp;
($Class_name, $NetID, $Course_Desc, $IEmail) = split(/\|/, $_);
$Class_Info{$Class_name} = {
'0' => $NetID,
'1' => $Course_Desc,
'2' => $IEmail
};
}
But the resulting hash isn't keyed by the $Class_name, the elements are just extended beyond the last element so the Class_name from the 2nd line becomes element 5 in the hash etc. Just keeps going on and on.
I know that I am missing something and my brain and my time are growing short. Hopefully someone can see something obvious and advise?
Thank you all so much.
hash{key}{0} = 1st field
hash{key}{1} = 2nd field
hash{key}{2} = 3rd field
So I can retrieve it last by referencing hash{key}{0,1 or 2}
Here is what my flat file look like:
law7505-01|kas02021|Contracts 1|email1.address\@sub.domain.edu
law7505-02|lsk02002|Contracts 2|email2.address\@sub.domain.edu
.etc.
Here is my current code:
while (<IFH>) {
chomp;
($Class_name, $NetID, $Course_Desc, $IEmail) = split(/\|/, $_);
$Class_Info{$Class_name} = {
'0' => $NetID,
'1' => $Course_Desc,
'2' => $IEmail
};
}
But the resulting hash isn't keyed by the $Class_name, the elements are just extended beyond the last element so the Class_name from the 2nd line becomes element 5 in the hash etc. Just keeps going on and on.
I know that I am missing something and my brain and my time are growing short. Hopefully someone can see something obvious and advise?
Thank you all so much.