use strict; use warnings; use Text::CSV; my %wordlist; { my $csv = Text::CSV->new(); while ( my $line = ) { $csv->parse( $line ) or die "Improperly formatted CSV string: $line"; foreach my $field ( $csv->fields() ) { foreach my $word ( split /\s+/, $field ) { next unless $word; $word =~ s/[^[:alpha:]'-]//g; $wordlist{lc $word}++; } } } } printf "%-16s: $wordlist{$_}\n", $_ for sort keys %wordlist; __DATA__ hi, there, world, how, are you, today? What are you up to? Here's a word with an apostrophe. test3