note
cdarke
Not sure which part you are puzzling over. Simplistically: <code>
use strict;
use warnings;
my $VAR1;
$VAR1 = {
'127' => {
'network' => '10.182.48.0/24',
'VLAN' => '3509'
},
'32' => {
'network' => '10.182.12.0/25',
'VLAN' => '2121'
},
'90' => {
'network' => '10.183.243.128/25',
'VLAN' => '3494'
}
};
sub custom {
# $a and $b are keys
my $anet = $VAR1->{$a}{network};
my $bnet = $VAR1->{$b}{network};
return $anet cmp $bnet;
}
my @result = sort custom keys %$VAR1;
</code>
However it would probably be better to use [mod://Net::IPAddress] to convert the IP address to a 32-bit int, then use <=> to compare them, and compare the ports if the addresses are the same.
970879
970879