in reply to Errors on loops over data

0 .. $#categories runs through 0, 1, & 2; but the third element of your @data only contains 2 elements: [7,8], so when you do my $val = $d->[$c]; on the third iteration of the outer loop, $val gets set to undef hence the error when you try to use $val as a hash key in line 23.

The solution is "don't do that" :)

if( defined $val ) { $h{$val}=$cat; } else { ## Do something else (or nothing). }

What alternative action you should take is very much dependant upon your application requirements.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)