# Script to go through file and count the number # of times an ip appears; use strict; use warnings; my $file = 'd:\temp\file.csv'; my %hash; open (FILE, $file) or die "Can't open $file: $!\n"; while (){ my($src, $dst, $rule1) = (split /,/)[1]; $hash{$src} = $src; next if $src =~ /$hash{$src}/; } my $count; for (keys %hash){ while (){ if ($_ =~ /$hash{$_}/){ $count++; } $hash{$_}{times} = $count; } } for my $ip (keys %hash){ print "$ip was seen $hash{$ip} times\n"; }