in reply to Fuzzy Matching
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.
|
|---|