I need to figure out how to compare each value in an array with each value in another array. This is for the same script I am writing for an excel price sheet. I thought it was done, but it seems that I need to compare each cell from column A with all of Column D looking for a match. so if there are 10 items in Array 0 from column A, I need it to start at Column A
row 2 and see if that value is anywhere in Column D, then move on to Col A Row 3 and check to see if that value is matched
in Col D and so on. until All 10 items have been looked for in column D. They dont need to be matched in the opposite direction.
this is the code I have now, it perfectly compares the columns line by line. not what I need it turns out.
#!/usr/bin/perl
use strict;
use Spreadsheet::XLSX;
my $excel = Spreadsheet::XLSX -> new ('build.xlsx');
my $sheet = $excel->Worksheet('Sheet1');
my ($row_min,$row_max) = $sheet->row_range();
my @col=();
for my $row ($row_min..$row_max){
$col[0] = $sheet->{Cells}[$row][0]->{Val};
$col[3] = $sheet->{Cells}[$row][3]->{Val};
#print "$row $col[0] $col[3] \n"
#print "$col[0] $col[3] \n"
foreach ($col[0]) {
if ($col[0] eq $col[3]) {
open FILE, ">feckyou.txt" or die $!;
print FILE "price has changed for $row \n";
close FILE;
}
}
}
I was trying to see if that foreach would go through $col[0] and compare each value with all of $col[3]. Apparently not.
help