in reply to Re: Counting the Number of Times and IP Appears
in thread Counting the Number of Times and IP Appears

Thank you everyone for your help, here's what my final code looks like that does what I need.
# Script to go through file and count the number of # times an ip appears; use strict; use warnings; my $file = 'd:\temp\text.csv'; my %hash; open (FILE, $file) or die "Can't open $file: $!\n"; while (<FILE>){ my($src) = (split /,/)[1]; $hash{$src}++; } foreach my $ip (sort({$hash{$b} <=> $hash{$a}} keys %hash)) { print "$ip appears $hash{$ip} times\n"; }