in reply to Reading data into a hash of hashes.
Line 17 is your problem--you're reassigning the hash, rather than just adding to it. Change this:
%mdata = ( $pkey => { ABC => trim_trailing($rec[1]), DESC => trim_trailing($rec[2]), UNIT => trim_trailing($rec[3]), LOC => trim_trailing($rec[4]) } )
to this:
$mdata{$pkey} = { ABC => trim_trailing($rec[1]), DESC => trim_trailing($rec[2]), UNIT => trim_trailing($rec[3]), LOC => trim_trailing($rec[4]) };
While you're at it, I'd suggest changing:
next unless (s/\^/\^/g == 4); my @rec = split /\^/;
to:
my @rec = split /\^/; next unless @rec == 5;
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|