Hash ref problem in Plucene::Simple (while searching a term)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I am just beginning to use Plucene::Simple module.
And the following code below tries to search a term in
indexed documents/files which are stored in a subdirectory "$tmp/"

Sample files I use are in this format:
Dir: /tmp/
file1.txt ---> content: test test
file2.txt ---> context: test test

However when I tried to print out the search result
it gives this error:

Can't use string ("test test") as a HASH ref while "strict refs" in
use at /usr/lib/perl5/site_perl/5.8.0/Plucene/Simple.pm line 235.

I have been scratching my head for a while to do this,
but still got no clue what went wrong.
Can anybody explain why this is?

Thanks and hope to hear from you again.


#! /usr/bin/perl -w

use strict;
use Plucene::Simple;
use Data::Dumper;

my $dir = "tmp/*"; #sub directory where I store files to be indexed
my %documents = ();

%documents = map { $_ => do { local ($/,*F); open F, "<$_"
                   or  die "Error reading '$_': $!"; <F> }} glob($dir);
# end of populating hash from files with file name as key and its content  
as values, successfuly.
# $VAR1 = {
#          'tmp/file2.txt' => 'test test',
#          'tmp/file1.txt' => 'test test'
#        };

#Begin Indexing
     my $index = Plucene::Simple->open( $dir );

     for my $id (keys %documents) {
         $index->add($id => $documents);

#do text search
my @ids = $index->search('test');
print Dumper \@ids;


Site Timeline