Jörg Walter > Tie-SymlinkTree > Tie::Indexer

Download:
Tie-SymlinkTree-1.1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.1   Source  

NAME ^

Tie::Indexer - fast searches through complex perl structures/ties

SYNOPSIS ^

 use Tie::SomeModule
 tie %hash, 'Tie::SomeModule', 'some_parameter';
 $hash{'one'} = "some text";         # Creates symlink /some_directory/one
                                     # with contents "some text"
 $hash{'bar'} = "some beer";
 $hash{'two'} = [ "foo", "bar", "baz" ];
 $hash{'three'} = {
   one => { value => 1, popularity => 'high'},
   two => { value => 2, popularity => 'medium'},
   four => { value => 4, popularity => 'low'},
   eleven => { value => 11, popularity => 'medium'},
 };

 # Warning: experimental and subject to change without notice:
 my @entries = tied(%hash)->search(sub { m/some/ }); # returns ("some text","some beer")
 my $firstmatch = $hash{'two'}->search(sub { m/b/ }); # returns "bar"
 my @result1 = $hash{'three'}->search('popularity','medium'); # returns ($hash{'three'}{'two'}, $hash{'three'}{'eleven'})
 my @result2 = $hash{'three'}->search('popularity','=','medium'); # the same
 my @result3 = $hash{'three'}->search('popularity',sub { $_[0] eq $_[1] },'medium'); # the same
 print $hash{'two'}->id; # prints out "two"

DESCRIPTION ^

This module provides searches through entries in a tied hash or array. It was developed for use with Tie::SymlinkTree but should work with any module. All you need to do is to provide a method Tie::YourModule::_get_index($) which returns a (preferably tied) hashref where this module can store it's information in. That hashref must support nested hashes.

You will probably also want to provide a sub search which calls Tie::Indexer::search(@_).

For now, read the source to see how to create and rebuild indexes. This is still considered experimental.

AUTHOR and LICENSE ^

Copyright (C) 2004, Jörg Walter

This plugin is licensed under either the GNU GPL Version 2, or the Perl Artistic License.

syntax highlighting: