in reply to Unique visits - Webserver log parser

Well, since merlyn has given you an outline of the futility of the task you have set yourself ill throw you the solution to making your futility possible. ;-)

You need a hash. A hash is an associative array which means it associates a key with a value. Also there are some minor booboos in your code. Such as no strictures or warnings, no variable declarations and using .* when you shouldnt. Please read


my %ips; # This is a hash while (<FILE>) { # Read em in $ips{$1}++ if (/^(\d+\.\d+\.\d+\.\d+)\s-\s-/); # no dot star # I make no promises that the above is a valid # IP matcher. It will match IPs and other # things too.. } foreach my $ip (keys %ips) { # Print em out print "IP $ip $ips{$ip}\n"; }

HTH (at least on a functional level, on an intentional level I think you should listen to merlyn....)

Yves / DeMerphq
--
When to use Prototypes?