NAME

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


SYNOPSIS

  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


DESCRIPTION

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.


PACKAGE METHODS

__PACKAGE__->new($path)

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

Returns an object. Woot!


OBJECT METHODS

$obj->query($str)

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.


VERSION

1.1


DATE

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


AUTHOR

Aaron Straup Cope


NOTES


LICENSE

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.