Need to compare 2 databases. Help please!
Here is my problem.
I need to compare to text files. Data in the file is in this format:
Item number|Quantity
Example:
File 1:
40|1
35|2
36|1
or (40|1, 35|2, 36|1)
File 2:
35|1
42|2
36|0
or (35|1, 42|2, 36|0)
What I want to do is to comapre 2 databases based on the Item number.
Te result of this comparisson should be:
40|1
35|3
36|0
42|2
or (40|1, 35|3, 36|0, 42|2)
As you see, if File 2 contain the same item, quantities should be added, if quantity in file 2 = "0", it should change to "0" in File 1.
If item that is in File 2 is not present in File 1, it should be simply added to file 1. If item exist in File 1 and does not exist in File 2, it should remain in File 1.
Anyone who knows how to do this in Perl, please help me with the code for this!
Many thanks!
Alex
|