in reply to Counting the Number of Times and IP Appears
#!/usr/bin/perl # 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 (<FILE>){ my($src, $dst, $rule1) = split /,/, 3; $hash{$src}++; } for my $ip (keys %hash){ print "$ip was seen $hash{$ip} times\n"; }
Update: For some unknown reason I reposted the original code instead of mine. So here it is
|
|---|