Goal- look up value in a hash of 3 fields where middle is key field for
lookup. The build hash from text file part below is working fine.
Then I read in a transaction file with field $sicode which should
lookup/chain/match to the key ($sig)in the hash and find a weight (3rd field
in hash, $wgt), and a code, $type(1st field).
I can't get the basic lookup on key $sig to work.
I have created the hash from a text file thusly
while (<INFILE>) {
($type,$sig, $wgt) = split ','; # splits $_ by default
chomp $wgt;
print "2 $type $sig $wgt \n";# single-spaced output
$sigwgthash{$sig}{'type'} = $type;
$sigwgthash{$sig}{'wgt'} = $wgt;
}
-------
then verified its' existance in memory and can print each field by doing
foreach $key (sort keys %sigwgthash) {
print "$key has a wgt of $sigwgthash{$key}{'wgt'} \n";
--------
Now why is it so hard to find a basic "lookup value by key" using key field
from another file?? But remember, the key I need to use is the MIDDLE of
the 3 fields in the hash.
When trying a distinct lookup within a "foreach" read of the non-hash
transaction file, . I tried..
print "wgthash $wgthash sigwgt $sigwgthash{$sicode}{'wgt'} \n";
where $sicode is the field from the other file to be matched in the hash
keys. The other words in front are just to describe field in that debug
print line.
I get blanks/nothing... no match evidently.
Most tutorials, Perl Monks, etc do not seem to cover many basics one notch
above the most basic. I personally found the Programming Perl/Oreilly book
to be NOT very helpful.
Sure would appreciate any help.
RS
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]