I have a problem with hashes and trying to understand them, I have read
the perldoc intersection and looked into the Perl Cookbook, and still do
not understand how I should handle this problem.
I have a master file with part number and quantity in it. I also have a
file that has the same information in it, part number and quantity. Both
files are comma, delimited.
What I am trying to do is read in the Master file, and then read in the
second file. Compare the second file to the Master file and decrement
the quantity in Master file. Then print out the results
Example Master file:
1011-303, 3
1021-329, 2
1021-333, 1
1021-336, 1
1021-340, 2
1021-323, 1
1021-330, 1
1021-334, 1
1021-341, 2
Example Data file
1011-303, 2
1021-329, 2
1021-333, 1
1021-336, 2
1021-340, 1
1021-323, 1
1021-330, 1
1021-334, 1
1021-341, 1
2044-666, 1
Code follows .. You will see that I am missing the code in the foreach .
if that is what I need to use
<snip>
$fname = $ARGV[0] || "scanned.file";
open(Master, "master.file") || die ("Could not open file $!");
my %master_file = <Master>;
close(Master);
open(DATA, $fname ) || die ("Could not open file $!");
my $count=0;
# open my hash
foreach $item ( $fname )
{
#
# subratract the information in HasH % master_file
#
}
# print results
open(NewMasterList,">>Results.file") || die ("Could not write file $!");
close (DATA);
close (NewMasterList);
exit;
Any help would be greatly appreciated !!!
TIA
Larry Sandwick
Sarreid, Ltd.
Network/System Administrator
phone: (252) 291-1414 x223
fax : (252) 237-1592