in reply to Re^3: Counting occurence of a list of word in a file
in thread Counting occurence of a list of word in a file
open my $testo, "<File_Input/Testo.txt"; open my $conteggio, ">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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Counting occurence of a list of word in a file
by gone2015 (Deacon) on Nov 11, 2008 at 18:56 UTC |