November 15, 2011

perl sorting IP addresses

if you have to deal with big ass arrays of IP addresses in perl and you need to sort things. i recommend reading the following paper.

A Fresh Look at Efficient Perl Sorting - if you’re looking for a portable means to do an efficient multi-subkey record sorts this is a great run down on the machinery within perl to make it faster. acquaint yourself with the schwartzian transform.

yes, i know, you could just use Sort:Key:IPv4. but that’s not very portable and self-contained.

Creative Commons License