I'm not sure what the question really is, but maybe this will give you some ideas:

#Don't forget to use these! use warnings; use strict; my %in_file_b; my @aonly; my ($file_a, $file_b) = ('Names_Ticker.txt', 'Names_Offer.txt'); print("Importing two data files \n"); #Look at FILE_B first since we will be eliminating elements #from FILE_A based upon its contents open(FILE_B, "<$file_b") or die "Couldn't open $file_b for reading: $!\n"; while (<FILE_B>) { chomp; #the key will be the first four chars of the line, lowercase my $entry = lc( substr $_, 0, 4); #substr $_, -4 would get last fo +ur $in_file_b{$entry} = 1; } close FILE_B; open(FILE_A, "<$file_a") or die "Couldn't open $file_a for reading: $!\n"; while (<FILE_A>) { chomp; my $entry = lc( substr $_, 0, 4); #add the entire line if the value of $entry isn't in %in_file_b push @aonly, $_ unless exists $in_file_b{$entry}; } close FILE_A; print "@aonly\n"; 1;

Processing it like this avoids slurping one of the files into memory.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

In reply to Re: Fuzzy Matching by Art_XIV
in thread Fuzzy Matching by Tan

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.