while(<FILE1>){ my $value = <FILE2>; $hash{$_} = $value; } print FILE3 join("\n", map({"$_ = $hash{$_}"} keys %hash));
That will readu lines from file handle FILE1 and use it as a key, the value being the corresponing line in FILE2. Is it that simple? Is there some more logic I need to know about? Do you really want line1 from file1 to be the key to line1 from file2? If so that above will do it (I left out the actual opening of the files, but I assume you can do that part).
Update: You should chomp $value, as L~R so astutely points out in his code above.
A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you
His Holiness, The Dalai Lama
In reply to Re: adding text from different txt file into hash
by JediWizard
in thread adding text from different txt file into hash
by MrChat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |