in reply to Sorting Unique
prints...use warnings; use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my %words; my $tot = 0; while (<DATA>) { for my $word (split) { $words{$word}++; $tot++; } } print Dumper(\%words); print "The number of words in the file is $tot\n"; __DATA__ a b c d e f g h a b c
$VAR1 = { 'a' => 2, 'b' => 2, 'c' => 2, 'd' => 1, 'e' => 1, 'f' => 1, 'g' => 1, 'h' => 1 }; The number of words in the file is 11
|
|---|