#!/usr/bin/perl    
use strict;    
use warnings;


print "Saisir un  texte\n";
my $essai = <STDIN>;
chomp($essai);

my @words = split(/\W+/, $essai);
my %hash;
                      
for my $word (@words){
    $hash{$word}++;
}

# parcours des paires clé=>valeur
while ( my ($cle,$val)=each(%hash) ) {
    print "cle: $cle, valeur: $val\n";
}

my @list_keys = keys(%hash);
my @list_values = values(%hash); 
print "nb de mots différents:", $#list_keys+1,"\n";

my  $nb_mots=0;
for my $val (@list_values){
    $nb_mots += $val;
}
print "nb total de mots: $nb_mots \n";
