#!/usr/bin/perl -w use strict; use warnings; my %counter; print "This program records all of the words you type and counts how often you type them.\nPlease type in a list of words. Type done when you are finished.\n"; $counter{$_}++ while chomp($_ = ) && !/^done$/i; foreach my $line ( sort keys %counter ) { printf "You typed '$line' $counter{$line} time%s.\n", ($counter{$line} == 1) ? "" : "s"; }