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

#!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"
poj

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

    Now i understand

    But my probelm is to compare line by line, and not only find the word in the $uniq1,so i search by combination, may be i must use a hash of array to stock the word of each line

        if the line1 in file 1 contain: izetbegovic slobodan milosevic someday serbian peace

        your program put these words in %uniq1 as key

        line2 in file 2 : slobodan serbian peace serbs bosnia milosevic

        you put this line in @match

        now you grep $uniq1{$_} with @match, here you don't compare the line from @match with a line from the file1, but you campare it with all the word contained in file, and what i want is to compare line by line

        may be i'm not correct!?