Hello,
I am reading an apache file and parsing the data.
I need to display number of accesses per hostname, number of accesses, and
a percentage of the total accesses that each host accounted for as follows.
I am having a problem calculating the percentage ot total access.
Is there a way I can get the same results but sorting alphabetically?
I would have to sort by the value rather than key.
What I have tried results in losing the hits count.
# Sorting on hits high -> lowforeach my $key ( sort { $Hits{ $b } <=> $Hits{ $a } } (keys %Hits) ) { my $perc = $Hits{$key}/$ttl; printf "%6d %4d %5s\n", $Hits{ $key }, $perc, $key; }
This is what i get..
Hits %-age Resource
----- ----- -----
7 0 h10.163.23.98.static.ip.wi
6 0 ip98-179-8-48.om.om.cox.ne
4 0 ip98-168-193-160.om.om.cox