in reply to Re^2: Counting frequency of strings in files
in thread Counting frequency of strings in files

Sorry, there should be this:
@seen{@list} = map{($seen{$_}||0)+1} @list;

and to print the output into a file, just say:
open my $output_fh, '>', "filename.txt" or die $!; #while(my($string, $count) = each %seen){ foreach my $string(sort {$seen{$b} <=> $seen{$a}} keys %seen){ my $count = $seen{$string}; printf $output_fh "%-70s%d\n", $string, $count; } close $output_fh;