FLINTSTONES -- BARNEY, FRED, WILMA JETSONS -- MAX, TONY, WILMA SIMPSONS -- LISA, BARNEY, WILMA, HOMER ALCATRAZ -- ELIJAH, MAX, WILMA #### sub nice_list { return '' if @_ == 0; return shift if @_ == 1; my $last = pop; return join(', ', @_) . " and $last"; } my $unix; my @dopli; my @trainer; foreach $unix (@dopli){ @trainer = split ('=', $unix); my %is_eaten_by = ( $trainer[0] => [ qw($trainer[1]) ], ); foreach my $fruit (keys %is_eaten_by) { my $eaters = $is_eaten_by{$fruit}; my $num_eaters = @$eaters; my $s = $num_eaters == 1 ? 's' : ''; my $p = $num_eaters == 1 ? '' : 's'; print("$num_eaters person$p eat$s ${fruit}s: ", nice_list(@$eaters), "\n"); } } #### BARNEY can be found 2: FLINTSTONES SIMPSONS FRED can be found 1: FLINTSTONES WILMA can be found 4: FLINTSTONES JETSONS SIMPSONS ALCATRAZ MAX can be found 2: JETSONS ALCATRAZ and so forth...