Hello All,
I have two CSV files, the first file I'm using to create a hash table: The first file looks like this: 1, 11 2, 22 3, 33 4, 44 5, 55 #!/usr/bin/perl use strict; use warnings; my $file = "c:/brian/AX/hp_ax_items.csv"; open(FILE, $file) or die "Can't open the $file: $!\n"; my %hash; while(<FILE>){ chomp $_; # remove the newline my($key,$value) = split(/,/,$_); # split by commas $hash{$key} = $value; # assign the value here The second file looks like this: 1, 1, 2, 3, 4, 5, bowl cleaner, $10,000, 30 2, 1, 2, 3, 4, 5, kitchen cleaner, $20,000, 45 3, 1, 2, 3, 4, 5, hand cleaner, $15,000, 55 I'm trying to replace comp1, comp2, comp3, comp4, comp5 with the value from file one. This is what I have so far: my $file2 = "c:/brian/AX/ax_hp_comp_file.csv"; open(FILE2, $comp) or die "Can't open the $comp: $!\n"; while(<FILE2>){ chomp $_; my($hp_item, $comp1, $comp2, $comp3, $comp4, $comp5, $desc, $ytd, $item_class) = split(/,/,$_); print "$hp_item, $hash{$comp1}, $hash{$comp2}, $hash{$comp3}, $hash{$comp4}, $hash{$comp5}, $desc, $ytd \n"; } I would like the print out to look like this: 1, 11, 22, 33, 44, 55, bowl cleaner, $10,000 2, 11, 22, 33, 44, 55, kitchen cleaner, $20,000 3, 11, 22, 33, 44, 55, hand cleaner, $15,000 Below is the entire program. Could someone pls point me in the right direction? I'm stuck! :-) #!/usr/bin/perl use strict; use warnings; my $file = "c:/brian/AX/hp_ax_items.csv"; open(FILE, $file) or die "Can't open the $file: $!\n"; my %hash; while(<FILE>){ chomp $_; #remove the newline my($key,$value) = split(/,/,$_); #split by commas or whatever $hash{$key} = $value; #assign the value here my $comp = "c:/brian/AX/ax_hp_comp_file.csv"; open(COMP, $comp) or die "Can't open the $comp: $!\n"; while(<COMP>){ chomp $_; my($hp_item, $comp1, $comp2, $comp3, $comp4, $comp5, $desc, $ytd, $item_class) = split(/,/,$_); # foreach($key1 %hash) print "$hp_item, $hash{$comp1}\n"; } } Thank you!! Brian