in reply to Re: 2 newby questions
in thread 2 newby questions
#!/usr/bin/perl -w use strict; my ($counter, $words, %counter) ; print "This program records all of the words you type and counts how o +ften you type them.\nPlease type in a list of words. Type done when +you are finished.\n" ; chomp ($words = <STDIN>) ; while ($words ne "done") { chomp ($words = <STDIN>) ; if ($words eq "done") { last ; } $counter{$words}++ ; } foreach $words (keys%counter) { if ($counter{$words} <= 1) { print "You typed $words $counter{$words} time." } else { print "You typed $words $counter{$words} times." ; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 2 newby questions
by hbm (Hermit) on Jun 15, 2012 at 11:57 UTC | |
|
Re^3: 2 newby questions
by Anonymous Monk on Jun 15, 2012 at 13:09 UTC | |
|
Re^3: 2 newby questions
by aaron_baugher (Curate) on Jun 15, 2012 at 04:38 UTC |