#!PERL.EXE -w
use strict;

my %count;

print "Please enter the items line by line.\nEnter a blank line to end counting items\n\n";
for (;;)
{
    my $item=<STDIN>;
    chomp($item);
    if ($item eq "")
    {
        last; # break;
    }

    if (  defined( $count{$item} )  )
    {
        $count{$item}++;
    }
    else
    {
        $count{$item}=1;
    }
}

print "Listing items:\n";
{
    my $item;
    foreach $item (keys(%count))
    {
        print "$count{$item} - $item\n";
    }
}

print "\nPress ENTER";
<STDIN>; # press ENTER to contiune