I don't know how even start.
Rather than providing a full solution, I will give you an algorithm, and start you on the first step.
- Read your conversion file into a hash.
- Loop through your data file line-by-line.
- Split it into tokens.
- Match the ID to a key of the hash.
- Print it out in the format you desire.
use strict;
use warnings;
my %conv;
open my $fh, '<', 'conv.txt' or die "can not open conv.txt\n";
while (<$fh>) {
chomp;
my ($k, $v) = split;
$conv{$k} = $v;
}
close $fh;
Try to understand that code, then ask questions if necessary. If you already know how to open files, then post the code you have so far, and post the actual output you are getting if it differs from your expected output.
Have you looked at the official Perl documentation yet? perlintro
In the future, post your data inside code tags. Refer to Writeup Formatting Tips.
| [reply] [d/l] |
If you are under linux or similar OS, you may just use the join utility. In such a case, the files must be sorted and IDs must be unique, though. | [reply] |