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,
220.127.116.11 => 2,
18.104.22.168 => 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?)