% cat AnagramWordList foo bar baz % cat 690557.pl #!/usr/bin/env perl use strict; use warnings; my $wordfile = 'AnagramWordList'; my %hashlist; ### It is a good practice to use the 3-argument form of "open" open my $wordhandle, '<', $wordfile or die "Unable to open WordList: $!"; while (<$wordhandle>) { chomp; ### Remove newline character $hashlist{$_}++; ### Add word to hash } close $wordhandle; ### It is a good practice to close the file ASAP ### Print out contents of hash while (my ($key, $value) = each %hashlist) { print "key=$key, value=$value\n"; } % ./690557.pl key=bar, value=1 key=baz, value=1 key=foo, value=1