<?xml version="1.0" encoding="windows-1252"?>
<node id="1020705" title="Add part of one hash to another" created="2013-02-26 10:11:47" updated="2013-02-26 10:11:47">
<type id="115">
perlquestion</type>
<author id="1020699">
batrams</author>
<data>
<field name="doctext">
Hi - I have two similar but different csv data files:

&lt;p&gt;
File A
Field 0: Part Number
Field 1: Description
Field 2: Price
&lt;/p&gt;
&lt;p&gt;
File B
Field 0: Part Number
Field 1: Description
Field 2: New Part Number
Field 3: Price
&lt;/p&gt;
I read File A's data in using this code. I'm sure it can be done in other or more efficient ways but this works well for me:&lt;/p&gt;

&lt;code&gt;
#################################
# reading data in from File A

 while ( &lt;&gt; ) {
    $csv-&gt;parse($_);
    push(@AoA, [$csv-&gt;fields]);
 }

# load up the hash
for my  $i ( 0 ..  $#AoA ) {

$HoA{$AoA[$i][5]} = $AoA[$i];

} # end looping over rows
#################################
&lt;/code&gt;

I then read File B's data in a similar way:

&lt;code&gt;
#################################
# reading data in from File B
while ( &lt;TEXTFILE&gt; ) {
    $csv-&gt;parse($_);
    push(@H_USES, [$csv-&gt;fields]);
   }
close(TEXTFILE);
print "Done Loading USES Data\n";

# load up the hash
for my  $i ( 0 ..  $#H_USES ) {
$H_USES{$H_USES[$i][5]} = $H_USES[$i];
} # end looping over rows
#################################
&lt;/code&gt;

Now I want to append data from File B onto the the hash I made from File A. If the file structures were identical I could simply do this:

&lt;code&gt;
##################################
# Add on File B's data
for my  $i ( 0 ..  $#H_USES ) {
$HoA{$H_USES[$i][5]} = $H_USES[$i];
} # end looping over rows
##################################
&lt;/code&gt;

But of course they are not identical. I want to simply ignore or skip over Field 2 from File B. I'm having trouble cooking up how to do this, so I thought I'd ask the gurus here. Any ideas would be appreciated.
</field>
</data>
</node>
