Update of /cvsroot/netpass/NetPass/lib/NetPass
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32100/lib/NetPass
Modified Files:
Network.pm
Log Message:
sorting by ipaddr on network, switch, netgroup and bynet Admin forms
Index: Network.pm
===================================================================
RCS file: /cvsroot/netpass/NetPass/lib/NetPass/Network.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Network.pm 31 Aug 2005 20:09:17 -0000 1.6
+++ Network.pm 6 Sep 2005 20:29:18 -0000 1.7
@@ -143,7 +143,8 @@
sub ip2int {
my $i = shift;
-
+
+ $i =~ s/\/.*$//; # get rid of any subnet mask
if ($i !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
die Carp::longmess("ip2int: \"$i\" doesnt look like an ip address to me");
}
@@ -155,6 +156,19 @@
($o[3] ) );
}
+=head2 @list = ipsort($aref)
+
+Given an array ref containing IP addresses. Sort them so they
+are ascending and return a new list.
+
+=cut
+
+sub ipsort {
+ my $ar = shift;
+ return [] unless (ref($ar) eq "ARRAY");
+ return sort { ip2int($a) <=> ip2int($b) } @$ar ;
+}
+
=head2 $ip = host2addr($hostname || $ipaddress)
Given a hostname, translate it (using Net::DNS) to its corresponding
|