The way I understand your problem, you have several errors in your code...
# if @ds1_rows is an AofA holding a dataset, then... for my $a ( @ds1_rows ) { # $record1 is an array, not a scalar... you are deref-ing # an arrayref and assigning it to a scalar, which doesn't # make any sense my $record1 = "@$a"; my $bool = ''; # then, further on... # you are assigning each element to $aref # (where is the 'my'?)... for $aref ( @ds2_rows ) { # and then, not using $aref... # instead, you are using $a again my $record2 = "@$a";

That said, lets ponder over what you mean by "one record at a time to all records in a second set to see if there's a match." Do you mean to compare an entire record, by which you seem to imply an entire row, with each entire row in the second set? I mean, if each row has 10 columns, do all the 10 columns have to be identical to all the 10 columns in another row for the two to be identical? That is a bit confusing.

In any case, you want to compare two arrays (well, AofAs in this case, but still arrays nonetheless) and compute their intersection. From the Cookbook, you get

#Simple solution for union and intersection foreach $e (@a) { $union{$e} = 1 } foreach $e (@b) { if ( $union{$e} ) { $isect{$e} = 1 } $union{$e} = 1; } @union = keys %union; @isect = keys %isect;
Apply the above logic. Or, loop over one array, and for each element, grep through the other array. Check out the usage of grep to search for an value in an array.

Hope all this helps.

--

when small people start casting long shadows, it is time to go to bed

In reply to Re: Printing the values of unique database records from comparing arrays of records by punkish
in thread Printing the values of unique database records from comparing arrays of records by Anonymous Monk

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.