<?xml version="1.0" encoding="windows-1252"?>
<node id="1012970" title="Re: Join files using perl" created="2013-01-11 15:17:57" updated="2013-01-11 15:17:57">
<type id="11">
note</type>
<author id="421781">
Cristoforo</author>
<data>
<field name="doctext">
Using this data (file 1 and file 2):
&lt;c&gt;ID1     50
ID2     60
ID3     100
&lt;/c&gt;
&lt;c&gt;ID1     20
ID2     100
ID3      10
&lt;/c&gt;

I got the results:
&lt;c&gt;
C:\Old_Data\perlp&gt;perl t9.pl o44.txt o55.txt
ID1     50      20
ID2     60      100
ID3     100     10

C:\Old_Data\perlp&gt;&lt;/c&gt;

The code is:
&lt;c&gt;#!/usr/bin/perl
use strict;
use warnings;

my %data;
while (&lt;&gt;) { # reads 2 files from @ARGV - filenames are on the command line
	my ($id, $val) = split;
	push @{ $data{$id} }, $val;
}

for my $id (sort keys %data) {
	print join("\t", $id, @{ $data{$id} }), "\n";	
}
&lt;/c&gt;</field>
<field name="root_node">
1012948</field>
<field name="parent_node">
1012948</field>
</data>
</node>
