b_vulnerability has asked for the wisdom of the Perl Monks concerning the following question:
[Nn]ucle[oi]:[Pp]roton[oi] OCS:chip [Ff]otosistema:LHC N2:[aA]zoto [Cc]enobio:[Cc]appell[ae] [Ee]sercit[oi]:[Ll]egion[ie] [Tt]erreno:sabbia [Ll]attosio:[Gg]lucosio codice:lettera
#!/usr/bin/perl use strict; use warnings; open my $listaParole,"File_Input/Coppie_Parole.txt" or die; my %hash; while (my $line=<$listaParole>) { chomp $line; my ($word1, $word2) = split /:/, $line; $hash{$word1} = $word2; } open my $testo, "<File_Input/Testo.txt"; open my $conteggio, ">File_Output/Conteggio.txt"; my %arrayris; my $indice=0; while (my $text=<$testo>){ for my $key (keys %hash){ my $value = $hash{$key}; my $arrkey=$key." "; my $count = 0; $count += () = /\b$key\b/ig while <>; print $conteggio "$arrkey) => $count\n"; } } close $testo; close $conteggio;
|
|---|