in reply to Unique visits - Webserver log parser

Any problem that basically says, have I seen this element or how many times have I seen this is ideally suited for a hash.
# Change while (<FILE>) { /(.*)\s-\s-/; $ip = $1; if (notInList($ip)) { $i++; addToList($ip); } } # To my %IPs_Seen = (); while (<FILE>) { # Add 1 to the key $1 (The match) $IPs_Seen{$1} ++ if m/^(.*)\s-\s-/; } #later print "\nVisits for $file is ",scalar(keys %IPs_Seen),"\n"; # To access the ips found. my @ips = keys %IPs_Seen;
This leaves out a host of other issues but it's a first step. #1 Visitors and IPs don't have a 1 to 1 mapping (proxies/AOL/etc). It will probably save you a ALOT of subroutine calls and the scanning of the @iplist on a file that big though.
What if you have a line that doesn't start with a valid ip? There are probably many other issues as well. That aside, there are many log parsing packages that are already out there. No need to reinvent the wheel unless of course you want the experience or want something different. Re-inventing wheels (or trying to) can be a great learning experience.

-Lee

"To be civilized is to deny one's nature."