If you dont like using pack. Or you have another type of data in the future, remember than cmp and <=> return 0 if they are the same. See below.
sort { my @a = split(/\./, $a); my @b = split(/\./, $b); $a[0] <=> $b[0] || $a[1] <=> $b[1] || $a[2] <=> $b[2] || $a[3] <=> $b[3] } @list
In reply to Re^2: sorting ip octets
by eclark
in thread sorting ip octets
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |