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