creating a hash
Posted on 2000-03-25
I have a file containing IP addresses. I want to read a file, and make a hash with IPs being the keys and the number of times that IP appears in the file as the value. So a file like this:
would create a hash like this:
%ips = (
0.0.0.0 => 1,
126.96.36.199 => 2,
188.8.131.52 => 3,
What I really need this for is counting IP accesses in a log file. I'll parse the log file, and:
1. if the IP is not already in the hash, add a key/value pair of <IP>=>"1".
2. if the IP is already in the hash, increment the value.
(how is this done?)