in reply to adding text from different txt file into hash

MrChat,
The following code is a starting point. You need to modify it accordingly to your given situation (how to handle files of difference number of lines, duplicates, or preserving order for instance).
#!/usr/bin/perl use strict; use warnings; open(FILE1, '<', 'file1.txt') or die $!; open(FILE2, '<', 'file2.txt') or die $!; open(FILE3, '>', 'file3.txt') or die $!; my %hash; while ( <FILE1> ) { chomp; my $val = <FILE2>; chomp $val; $hash{ $_ } = $val; } print FILE3 "$_ = $hash{ $_ }\n" for keys %hash;

Cheers - L~R