in reply to split and sort functions

Can I assume your original data is sorted, and you really just want to maintain the original order? Then you want something like Tie::IxHash. There are several of those modules, like Tie::Hash::Indexed, which is written in XS (the former is in Pure Perl) and thus, probably faster.

Perhaps you do want your hash to be automatically sorted. In that case, you might be interested in something that works like a hash, but internally keeps the keys sorted, something like a binary search tree. I don't know immediately of something that you could use instead of a hash, but perhaps, assuming your hash keys are always integers, a Judy Array might work for you. There's an XS implementation for Perl in Tie::Judy. The docs there say: "the keys here are in bit-wise SORTED order".