http://qs321.pair.com?node_id=431692


in reply to sorting ip octets

Or, a somewhat more readable version:
my @ips = <DATA>; $_ = sprintf("%03d.%03d.%03d.%03d", split /\./) for (@ips); @ips = sort @ips; $_ = sprintf("%d.%d.%d.%d", split /\./) for (@ips); print join "\n", @ips; __DATA__ 127.0.0.1 10.129.30.5 10.129.30.2 255.255.255.255 10.109.30.5 142.222.130.23 10.109.1.1 142.222.87.30
Basically, you convert to fixed width (3 chars per octet), sort, and convert back to the original unpadded numbers.