in reply to Parsing tomcat access log
I need to get the count of unique IP addresses , count of unique URLs and...
For counting unique things, it's usually more appropriate to use the item of interest (such as the URLs) as the hash's key...
After having put all items in the hash, the number of keys indicates the number of unique items.
my @things = qw(foo bar foo baz baz); my %hash; $hash{$_}++ for @things; print scalar keys %hash; # 3
|
|---|