use strict; use warnings; #declare variables my %hash; my $data; #opening Files open my $in, '<',"./Test_Data_RanNumbers.txt" or die ("can't open the file:$!\n"); open my $in1,'<',"./Test_Data_More_RanNumbers.txt" or die ("can't open file : $!\n"); open my $out ,'>' ,"./Test_Data_Out_Ita_SpanFrenEngGer.txt" or die "can't open the file for write:$!\n"; open my $out1,'>',"./Test_data_out_Ita_SpanFren.txt" or die "can't open the file :$!\n"; open my $out2,'>' , "./Test_Data_Out_None_Match.txt" or die "can't open file for write:$!\n"; while ($in){ #data manipulation to clean up ='s and ,'s #dieci = diez, zehn -->worse case, remove spaces and = and comma; #quattro = quatro -->only one number with spaces or not in from of =... chomp($data); my ($ita,$spa,$num)= split(/[=\s,]+/,$data); # removes '=' or 's' or ',' & '+' to match 1 or more these characters $hash{$ita}[0]=$spa; $hash{$ita}[1]=$num; #keeping it for check later if "defined" | will be undef if not } close $in; while ($in1){ chomp($data); my ($ita,$fren,$num)= split(/[=\s,]+/,$data); $hash{$ita}[0]=$fren; $hash{$ita}[1]=$num; #keeping for check later checks programming } close $in1; foreach my $ita (keys %hash){ if($hash{$ita}[0] and $hash{$ita}[1]){ print "$ita =>", join(',',@{$hash{$ita}}),"\n"; }else { print "$ita =>",join(',',@{$hash{$ita}}),"\n"; } }