I have a large file of names data with the source data in English and the corresponding equivalent in a different script. The two are delimited by an equal to sign.

=

It so happens that because of data entry mismatch occurs between the number of names in English data does not find an equivalent in the corresponding scripts. Thus 3 names in English map to 2 names in the target language and so on. I am giving a pseudo-example below.

Peter=Pierre John Baker=JeanBoulanger Mary Brown Smith=Marie Brown

With the help of the internet the I wrote a perl script which can separate out the matched from the not-matched and in the non-matched file indicate if possible provide the degree of deviation:

Matched file JPeter=Pierre Notmatched file John Baker=JeanBoulanger(1) Mary Brown Smith=Marie Brown(1)

Here it is below:

#!/usr/bin/perl use strict; use warnings; open(FILE, "<try"); while (my $line = <$try>) { my ($left, $right) = split /=/, $line; my @left_array = split / /, $left; my @right_array = split / /, $right: my $left_count = scalar @left_array; my $right_count = scalar @right array; if ($left_count == $right_count) { print $matched_file $line; } else { chomp $line; my $diff = abs (left_count - $right_count) print $unmatched_file $line, "($diff) \n"; } }

Since I am a newbie to Perl, I guess I have goofed up and I consistently get dumps.

Please help

In reply to Identifying unmatched data in a database by ardibehest

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.