NAME
Sort::Key::IPv4 - sort IP v4 addresses
SYNOPSIS
use Sort::Key::IPv4 qw(ipv4sort);
my @data = qw(1.1.1.1 1.1.1.0 1.1.1.2 2.1.0.3);
my @sorted = ipv4sort @data;
use Sort::Key::IPv4 qw(ipv4keysort);
my @sorted = ipv4keysort { $_->ip_address } @hosts;
DESCRIPTION
This module extends the Sort::Key family of modules to support sorting of IP v4 addresses.
IPv4 addresses have to match the regular expression /^(\d)+\.(\d)+\.(\d)+\.(\d)+$/
.
FUNCTIONS
The functions that can be imported from this module are:
- ipv4sort @data
-
returns the IPv4 addresses in
@data
sorted. - ripv4sort @data
-
returns the IPv4 addresses in
@data
sorted in descending order. - ipv4keysort { CALC_KEY($_) } @data
-
returns the elements on
@array
sorted by the IPv4 addresses resulting from applying themCALC_KEY
. - ripv4keysort { CALC_KEY($_) } @data
-
is similar to
ipv4keysort
but sorts the elements in descending order. - ipv4sort_inplace @data
- ripv4sort_inplace @data
- ipv4keysort_inplace { CALC_KEY($_) } @data
- ripv4keysort_inplace { CALC_KEY($_) } @data
-
these functions are similar respectively to
ipv4sort
,ripv4sort
,ipv4sortkey
andripv4sortkey
, but they sort the array@data
in place. - ipv4_to_uv $key
-
converts the IPv4 value to a 32 bits unsigned integer.
SEE ALSO
COPYRIGHT AND LICENSE
Copyright © 2007, 2009 by Salvador Fandiño, <sfandino@yahoo.com>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.