open my $testo, "File_Output/Conteggio.txt"; my %arrayris; while (my $text=<$testo>){ for my $key (keys %hash){ my $value = $hash{$key}; my $count = 0 ; while ($text =~ /\b$key\b/ig) { $count++ ; } ; $arrayris{$key}=$count; } } while ( my ($k,$v) = each %arrayris ) { print $conteggio "($k) => $v\n"; } close $testo; close $conteggio;