I am beginning to delve deeper into Perl, but am having trouble writing \"Perl-ly\" code instead of writing C in Perl. How can I change the following code to use more Perl idiom
The majority of your code is manipulating 2D arrays. I think the biggest improvement would be switching to using PDL if you want to do much stuff with arrays, particularly if efficiency is a concern. It's a Perl module which provides excellent array support. The underlying routines are implemented in C for efficiency so it's fast too.