ASCOPE::Search::Boolean - Aaron's generic boolean search class.


  my $search = ASCOPE::Search::Boolean->new($list);
  my $result = $search->query("foobar");
  print $result;
  # prints:
  # a-oooooooo-ga!
  print $result->query();
  # prints:
  # foobar
  print ref($result);
  # prints:
  # ASCOPE::Search::Boolean::result


This is Aaron's generic boolean search class.

It performs lookups on files containing foo\tbar\n style lists using a boolean search.

Hashes in Perl are super cool but they come at the expense of being pretty big in terms of memory. And if you have a long list of foo->bar query pairs then you also have a *very* big hash.

Some people take their lists and write them to a file and simply loop over every line which is, overall, better in terms of memory usage. Except if your file is very long or your lookup is all the way at the end.

Ultimately, it depends on the size of your list. If you've only got 4-5 thingies then a hash is fine. But if you've got a couple hundred entries and you can imagine it growing using a boolean search is worth the trouble as it is very fast and doesn't have the same overhead.



Where $path is the path to a file containing your foo->bar pairs. see also: examples/diacratics.txt

Returns an object. Woot!



Returns under if no match was found.

If a match is found, returns an ASCOPE::Search::Boolean::result object.

A ::result object's ``'' operator is overloaded and will return the result of your query.

The object defines a single query method which will return the text used to retrieve the result itself.




$Date: 2003/04/09 14:10:52 $


Aaron Straup Cope



Copyright (c) 2003, Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.