in reply to Counting frequency of strings in files

You could accumulate words into a hash:
use warnings; use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my %words; while (<DATA>) { $words{$_}++ for split; } print Dumper(\%words); __DATA__ the the the and me ok big dog me

Prints:

$VAR1 = { 'and' => 1, 'big' => 1, 'dog' => 1, 'me' => 2, 'ok' => 1, 'the' => 3 };

See also: