in reply to Re^12: compare two text file line by line, how to optimise
in thread compare two text file line by line, how to optimise
while (<FICC>) { my @words = split /\s+/,lc $_; ++$uniq1{$_} for @words; }
$uniq1{$_} contains all the words from file1 like a dictionary. $uniq1{'anyword'} will be undef or 0 if 'anyword' was not in file1.
Try a simple example
poj#!perl my %uniq1= ( cow => 1, dog => 1, fox => 1, ); my @words = ('ant','bat','cat','dog','eel','fox'); my @match = grep $uniq1{$_}, @words; print "@match\n"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: compare two text file line by line, how to optimise
by thespirit (Novice) on Mar 01, 2016 at 12:59 UTC | |
by poj (Abbot) on Mar 01, 2016 at 13:14 UTC | |
by thespirit (Novice) on Mar 01, 2016 at 16:36 UTC | |
by thespirit (Novice) on Mar 01, 2016 at 20:15 UTC |