#!/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 $input, "Wiki_Pulito/Prova/Conteggio.txt"; # Apro il file di output my $conto=0; my %arrayris; while (my $text=<$input>){ for my $key (keys %hash){ my $value = $hash{$key}; while ($text =~/(($key\/$key\/S)\s{0,2}(\.\*)\s{0,2}(con\/con\/E)\s{0,2}(\.\*)\s{0,2}($value\/$value\/S))/is){ $conto++; } my $arrkey=$key."-".$value; $arrayris{$arrkey}=$conto; } } while ( my ($k,$v) = each %arrayris ) { print $conteggio "($k) => $v\n"; } close $input; close $conteggio;