BEFORE:
- use
feature ':5.10';
-
-
-
- my
@words = ("We", "She", "We", "He",
"We", "It", "He", "We",
"She", "He");
- my
$word_count = @words;
-
- my
$i = 0;
- my
$we_counter = 0;
- my
$she_counter = 0;
- my
$he_counter = 0;
- my
$it_counter = 0;
-
- while
($i < $word_count){
-
- if
($word[$i] eq 'We')
{
- $we_counter++;
- $i++;
- }
-
- elsif
($word[$i] eq 'She')
{
- $she_counter++;
- $i++;
- }
-
- elsif
($word[$i] eq 'He')
{
- $he_counter++;
- $i++;
- }
-
- else
{
- $it_counter++;
- $i++;
- }
- }
-
-
- my
%report_list = ("We" => $we_counter, "She" =>
$she_counter, "He" => $he_counter, "It" =>
$it_counter);
-
-
- say
"\n___________________________________________\n
- say "
-
- say "
-
- say "
- say "
- say "
- say "
- say "
- say "
AFTER:
my %counts; $counts{$_}++ for @words;
:)
j
|