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,
188.8.131.52 => 2,
184.108.40.206 => 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?)