my %hash; my $file = 'filehere.txt'; open(DATA, "$file") || die "Can not open: $!"; while () { chomp($_); $hash{$_}++; } close(DATA);