in reply to matrix's

That's not how you do a multi-dimensional array in Perl. You should replace each instance of:
$table[$I,$K]
with
$table[$I][$K]
among other things. For example, when comparing two numbers, don't double-quote one of them. Etc.

Also check out Math::Matrix and PDL.