ok, now, I am stuck here. I spend time testing/reading on split with various delimiters.I learned how to remove stuff I don't want...

BUT

now I get some error I DON"T understand after 1.5 weeks of playing with perl. I'm so FRUSTRATED with my prgress!

can you help me out by explaining my error. I am too inexperience to SEE it myself.

first data key has random values of 2 or less numbers

uno = uno,eins due = dos,zwei tre = tres,drei quattro = quatro cinque = cinco,funf sei = seis, sette = siete,sechs otto = ocho nouve = nueve, neun dieci = diez, zehn undici = once, elf dodici = doce tredici = trece, dreizehn

2nd data may have 3 or less vaules

due =deux, two, tre = trois,drei, three quattro = quatre,four cinque = cinq,funf, five sei = six , six sette = sept , seven ,sechs dieci =dix undici = onze,eleven tredici = treize,thirteen, dreizehn
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 "ca +n't open the file for write:$!\n"; open my $out1,'>',"./Test_data_out_Ita_SpanFren.txt" or die "can't ope +n the file :$!\n"; open my $out2,'>' , "./Test_Data_Out_None_Match.txt" or die "can't ope +n file for write:$!\n"; while ($in){ #data manipulation to clean up ='s and ,'s #dieci = diez, zehn -->worse case, remove spaces and = and comm +a; #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" | wi +ll 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"; } }

In reply to Re^9: Need advice on checking two hashes values and keys by Anonymous Monk
in thread Need advice on checking two hashes values and keys by perlynewby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.