I have two bug fixes and a speed enhancement for you.
inet_aton doesn't return a number, yet you sort numerically.
sort { $a->[0] <=> $b->[0] }
should be
sort { $a->[0] cmp $b->[0] }
chop could drop the last char of the data in the file. (e.g. The file could be "10.0.0.1\n10.0.0.2\n10.0.0.5".) Use chomp instead of chop.
It's much faster to avoid creating numerous anonymous arrays and using the default lexical sort, and it's trivial to do here since inet_aton returns a fixed length string. See my post for details.
In reply to Re^2: How to sort IP addresses
by ikegami
in thread How to sort IP addresses
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |