use strict; use warnings; use Data::Dump qw(dump); my %hash; #my file handles UNTIL I figure how to install the Inline::File module to netbeans IDE open my $in, '<',"./test_data.txt" or die ("can't open the file:$!\n"); open my $in1,'<',"./test_data1.txt" or die ("can't open file : $!\n"); open my $out ,'>' ,"./test_data_out.txt" or die "can't open the file for write:$!\n"; open my $out1 ,'>',"./test_data_out1_no_match.txt" or die "can't open file for write:$!\n"; #creating hash while (<$in>){ chomp; my ($key,$value)= split(/\s*=\s*/); #conto di spazio prima o dopo la parola $hash{$key}=$value; } close $in; #using the first hash while (<$in1>){ chomp; my($key,$value)=split/\s*=\s*/ ; #push the value to existing hash as to get reference if key exists # %hash =( It => [Spa Fre]) #using one hash as per Ken code suggestion?? push @{$hash{$key}},$value if $hash{$key}; #non so come funziona "push" print $out dump (\%hash); } close $in1; close $out; close $out1;