"anything I prototype in Perl will ultimately be ported to C" Perl and C arrays are quite a bit different. Algorithms like this written for Perl will not necessarily perform well in other languages. This applies particularly to C and performance. You might find it quicker to write in C in the first place, otherwise you might find yourself writing Perl array handling in C, again.