Bizarre Question
Michael Fowler
michael at shoebox.net
Tue Apr 17 16:50:53 CDT 2001
On Tue, Apr 17, 2001 at 10:11:56AM -0800, Leif Sawyer wrote:
> What I'm trying to do, is print out a list of ports, by protocol,
> for each ACL. And i'd like the ports sorted by the number of packets,
> descending.
>From the code you showed us, I can't really see what you may have done
wrong. Perhaps it's that I don't understand how you wanted this sorted.
Anyhow, below my signature is the test code I used. Below this paragraph is
the output it produces, indented to distinguish it.
input-1
icmp
8 7000
tcp
110 4000
23 200
22 4
udp
53 7000000
31337 80000
input-2
icmp
10 4000
8 20
tcp
113 40
53 10
udp
53 700
Is this the sort order you were looking for? If not, you should take the
example data and restructure it so that we have a better idea of what you're
looking for.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
#!/usr/bin/perl -w
use strict;
# some seed data
my %services = (
'input-1' => {
tcp => {
23 => 200,
110 => 4000,
22 => 4,
},
udp => {
31337 => 80000,
53 => 7000000,
},
icmp => {
8 => 7000,
},
},
'input-2' => {
tcp => {
113 => 40,
53 => 10,
},
udp => {
53 => 700,
},
icmp => {
10 => 4000,
8 => 20,
},
},
);
foreach my $acl (sort keys(%services)) {
print "$acl\n";
foreach my $proto (sort keys(%{ $services{$acl} })) {
print " $proto\n";
foreach my $port (
sort { $services{$acl}{$proto}{$b} <=> $services{$acl}{$proto}{$a} }
keys(%{ $services{$acl}{$proto} })
) {
print " $port $services{$acl}{$proto}{$port}\n";
}
print "\n";
}
print "\n";
}
=================================================
Mailing list info: If at any time you wish to (un|re)subscribe to
the list send the request to majordomo at hfb.pm.org. All requests
should be in the body, and look like such
subscribe anchorage-pm-list
unsubscribe anchorage-pm-list
More information about the Anchorage-pm
mailing list