in reply to Simple Text Indexing
My first recommendation was MMM::Text::Search, but it too only tells you which file(s) the search words were found in, not where.
What are you building this for? Wouldn't a simple brute force loop be enough if you are only dealing with one file?
my $match = qr/thunderbird/i; open FILE, '<', 'foo.txt' or die $!; while (<FILE>) { if ($_ =~ $match) { my @word = split /\s+/, $_; $_ =~ s/[A-Za-z0-9_ ]//g; for my $i (0..$#word) { if ($word[$i] =~ $match) { print "match found on line $. word ", $i+1,"\n"; } } } }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple Text Indexing
by cyocum (Curate) on Nov 29, 2003 at 18:16 UTC | |
by diotalevi (Canon) on Nov 29, 2003 at 18:46 UTC | |
by cyocum (Curate) on Nov 30, 2003 at 12:02 UTC | |
by ysth (Canon) on Nov 30, 2003 at 12:10 UTC | |
by cyocum (Curate) on Nov 30, 2003 at 16:46 UTC | |
by diotalevi (Canon) on Dec 08, 2003 at 21:05 UTC |