As Laurent_R said, store the words into a hash for a fast look-up
#!/usr/bin/perl
use strict;
my $t0 = time;
# build dictionary
my $wordfile = 'words1.txt';
my %dict = ();
my $count = 0;
open my $in,'<',$wordfile
or die "Could not open $wordfile : $!";
while (<$in>){
chomp;
my ($motlexique,@cols) = split /\t/,$_;
$dict{$motlexique} = \@cols;
++$count;
}
close $in;
print "$count lines read from $wordfile\n";
# scan text file
$count = 0;
my $textfile = 'text1.txt';
open my $in,'<',$textfile
or die "Could not open $textfile : $!";
while (<$in>){
chomp;
my ($searchword,@cols) = split /\t/,$_;
if (exists $dict{$searchword}){
my $genre = $dict{$searchword}[3];
my $nombre = $dict{$searchword}[4];
#Do some things here
print "Matched '$searchword' to $genre $nombre\n"
}
++$count;
}
close $in;
my $dur = time - $t0;
print "$count lines read from $textfile in $dur seconds\n";
poj