# Change while () { /(.*)\s-\s-/; $ip = $1; if (notInList($ip)) { $i++; addToList($ip); } } # To my %IPs_Seen = (); while () { # 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;