Normalise/demormalise:
use strict; use warnings; my @ips = qw(123.156.89.12 12.245.67.1 12.45.67.180 12.145.66.20); @ips = map {sprintf "%d.%d.%d.%d", split /\./} sort map {sprintf "%03d.%03d.%03d.%03d", split /\./} @ips; print join "\n", @ips;
Prints:
12.45.67.180 12.145.66.20 12.245.67.1 123.156.89.12
In reply to Re: How to sort IP addresses
by GrandFather
in thread How to sort IP addresses
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |