First, you can shorten your code just a bit by removing the use of $_.

while (my $ptfkey = <F2>)

The regex where you read in file 2 has a couple of issues. First, it forces start and end of line matching (^ and $, respectively). Next, it only matches the pipe and the whitespace on either side of it, so it will only match lines with ' | \n'. Lastly, it deletes everything that it matches.

If you only need to identify information in the first column, you only need to do this:

while (<F2>) { $ptfkey = $_; # you can skip this using above suggestion $ptfpn = $ptfkey; # don't need this if just matching $ptfpn =~ m/^(\w+)/; # if only letters and numbers $ptfpn =~ m/^([\d\-\.]+)/; # if it's a float $F1hash{$1} = 1; }

Secondly, the line that checks for the value should be throwing you an error:

if ($PartNumber =~ $Flhash{$PartNumber}) {

(Or, there are some languages that treat '=~' as a negation, kind of like '!=', so it could just be a typo.)

All you need to do is check to see if the value exists in the hash we created above:

if (exists $F1hash{$PartNumber}) {

Hope this helps.

Edit: I also just realized you declared %F1hash twice -- you should add the following to your code:

#!c:\perl\bin\perl -w # note the addition of the -w use diagnostics; use strict;

In reply to Re: Question on file compare by muppetjones
in thread Question on file compare by sureshsmr

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.