in reply to Re: concatenation 2 values then pushing to a hash_ref
in thread concatenation 2 values then pushing to a hash_ref
sorry, I didn't mean to make you guess.
GOAL:find the common Italian number in both files that contains both Spanish and French translations (did that). Then,I added complexity to my learning by adding other number translations (german, english) and build the match file to contain these.
lastly, to dump the numbers that don't have a matching Italian number in any.
things I'd hope to learn.
1) HASH_REF 2) Print HASH_REF 3)conditionals (if,else,define) with hash_ref 4)Concat ( now, I know needs a (.) THANKS TO YOU! although I saw an example where it didn't and that's what I followed) 5) play with SPLIT to remove =,spaces:/ and stuff.
Questions for clarity
:EXAMPLE snippet1 I modeled my concat syntax, why the Difference? why mine didn't work?
chomp; my($col1,$col2,$rest)=split(/\t/); my $ckey="$col1$col2" #<= NO PERIOD!
question 2, what does this piece do?can you explain your addition of "!"? I'm thinking, if the $num is UNDEF then go into loop...is this thinking correct?
if (!defined $num){
Output of Not a match of Italian number in either file has a printing bug I would like to remove. Please note, there is no French number in spot1 and so it gives ",," instead, how to remove these?
nouve =>nueve,,neun uno =>uno,,eins
I build my hash as follows:
Italian => Spanish, French, whatever
so in this case, one number is not found in the other and so the spot is just filled with ",,"
NEED HELP:how to order the numbers on output?, any ideas???
CORRECTED my hash structure like this since concat didn't print like I wanted
my ($ita,$fren,$num1,$num2)= split(/[=\s,]+/); #creates col of num +bers $hash{$ita}[1]=$fren; #now hash_ref format will look like this: it +a=> spa , fren #define if there is are numbers in position 3 and 4 concat to posi +tion 3 if (defined ($num1)){ $hash{$ita}[3]=$num1; # % looks like this: Ita=> Spa, Fren, R +andNUM[3] } if (defined $num2){ $hash{$ita}[4]=$num2; # % looks like this Ita=> Span,Fren, Ra +ndnum[3]?(ifdefined), Randnum[4] } }
somehow I feel there is a better way to do this...can hash of hashes be better? I don't know yet, I guess I need to learn that next...
GRAZIE MILLE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: concatenation 2 values then pushing to a hash_ref
by Aldebaran (Curate) on Jun 12, 2015 at 09:57 UTC | |
by perlynewby (Scribe) on Jun 12, 2015 at 19:09 UTC |