#!/usr/bin/perl use strict; use warnings; my %wordcount = (); open(theFile,") { chomp($line); my @words = split(' ', $line); foreach my $word(@words) { $wordcount{$word} += 1; } } foreach my $key(keys %wordcount) { print "Word: $key Repeat_Count: " . ($wordcount{$key} ) . "\n"; }