Exulted ones,
Put simply, why doesn't this work!?
# compare each row in the first set of data to every row # in the second set of data. If it does not occur, then # they are different, so print. for my $a ( @ds1_rows ) { my $record1 = "@$a"; my $bool = ''; for $aref ( @ds2_rows ) { my $record2 = "@$a"; $found = $record1 eq $record2; $bool = $found; # set bool vari +able to value of found last if $found; } # if the boolean variable is equal to nothing, the for + loop was # not exited prematurely, thus no record was found mat +ching. if ($bool eq '') { $record_count++; } } # assign field names to values for each record that # is found to be different for (my $x = 0; $x < $record_count; $x++) { for (my $y = 0; $y < $field_count; $y++) { print $column_names[$y] . ": " . $ds1_rows[$x][$y] + . "\n" unless $found; } }
I've noticed there has been a number of articles quite recently that provide help related to what I am doing, but I can't find an answer to solve this problem.

The code above looks at database records stored in arrays (hence array of arrays) and compares one record at a time to all records in a second set to see if there's a match. If there isn't, then it's a unique record and the values of that record must be printed out with field names as a labels.
@ds1_rows and @ds2_rows are arrays of records of values. The number of record values in each record in each set is the same, however the number of records can vary. @column_names is a list of field names that match the number of values.

At the moment I think I can see if a record matches. I can also record the number of non-matches. I can print the column name as a label next to record values, however the records don't represent those that do not exist but are the records first in the array.

Please excuse the fact my code isn't as concise as it probably can be, i'm fairly new to programming and Perl so i've only used what I know and understand.

Cheers for any help that is given, Steve.


In reply to 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.