L'/lo/RDNS harmonium/harmonium/S Ë/essere/V-S3IP uno/uno/RIMS strumento/strumento/S-MS musicale/musicale/A-NS azionato/azionare/V-MSPR con/con/E una/una/RIFS tastiera/tastiera/S-FS #### [Nn]ucle[oi]/nucleo/S-MS:[Pp]roton[oi]/protone/S-MP [Aa]tom[oi]/atomo/S-MS:[Nn]ucle[oi]/nucleo/S-MS #### #!/usr/bin/perl use strict; use warnings; open my $listaParole,") { chomp $line; my ($word1, $word2) = split /:/, $line; $hash{$word1} = $word2; } while ( my ($k,$v) = each %hash ) { print "Key $k => $v\n"; } open my $testo, "Output"; my @arrayris =() ; my $indice=0; while (my $text=<$testo>){ for my $key (keys %hash){ my $value = $hash{$key}; while ($text =~ / $key (.*)? $value /g) { $arrayris[$indice]=$1; $indice++; } } } my $indice_controllo=1; foreach (@arrayris) { print $lista_relazioni "($indice_controllo) $_\n"; $indice_controllo++; } close $testo; close $lista_relazioni;