Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^9: Need advice on checking two hashes values and keys

by Anonymous Monk
on Jun 10, 2015 at 23:53 UTC ( [id://1129953]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Need advice on checking two hashes values and keys
in thread Need advice on checking two hashes values and keys

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"; } }

Replies are listed 'Best First'.
Re^10: Need advice on checking two hashes values and keys
by perlynewby (Scribe) on Jun 11, 2015 at 19:33 UTC

    never mind...forget about it ;-)

    I am back at it again with clear mind and eyes and I see what I need to do...I think my frustration disadvantage the best of me.

    I still like Perl ;-) until next bug in my code...but practicing

      Don't feel bad or get too frustrated, just keep plugging away and ask when you need help. Your problem may not seem that complicated, but anything involving multi-dimensional hashes is beyond what I'd consider beginner-level.

      When I started learning Perl 20 years ago, it was with a book called something like Learn Perl in 21 Days; and I already had some experience with C, awk, sed, and shell programming; but I probably still wasn't doing multi-level hashes in 1.5 weeks. It seems like people get thrown into the deep end a lot more these days -- maybe due to bosses not knowing what's hard and what's easy and not wanting to give people the proper time for training in the age of outsourcing -- so they don't get to follow a more natural learning curve. You're doing fine.

      Aaron B.
      Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1129953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found