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.
|
|---|