#!/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;