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


In reply to new dilemma on the same song that remains... umm the same by trickyq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.