Tie::Judy - Perl extension for using a Judy array instead of a hash.
use Tie::Judy; tie %judy, 'Tie::Judy'; # %judy now reads and writes to a Judy array. keys %judy; # the keys here are in bit-wise SORTED order. values %judy; # the values here are in the same order as the keys 0 + %judy; # returns the number of keys # method to add lots of entries at once (tied %judy)->insert( { key => 'value', ... } ); (tied %judy)->insert( key => 'value', ... ); # method to retrieve lots of values at once (tied %judy)->retrieve( 'key1', 'key2', ... ); # method to remove lots of entries at once (tied %judy)->remove( 'key1', 'key2', ... ); # search: flexible method to retrieve a subset of keys and/or values # with no arguments, returns all the keys (tied %judy)->search(); (tied %judy)->search( return => 'key' ); # same thing # can instead return values (tied %judy)->search( return => 'value' ); # or both keys and values (as a flat list) (tied %judy)->search( return => 'both' ); # or a list of array references (each with one key and one value) (tied %judy)->search( return => 'ref' ); # the set of entries can be filtered thusly: # (note that none of these arguments are required) (tied %judy)->search( min_key => 'from', max_key => 'to', limit => 100, # max number of entries returned key_re => qr{.{3}}, # the key must match this pattern value_re => qr{.{9}}, # value must match this pattern check => \&check, # sub gets key and value in @_, # should return true if entry # should be included ); # OBJECT-ORIENTED INTERFACE my $judy = Tie::Judy->new(); @keys = $judy->keys; @values = $judy->values; $count = $judy->count; $judy->insert( key => 'value', ... ); $judy->insert( { key => 'value', ... } ); # retrieve and remove return arrays in list context, array refs in scalar context $judy->retrieve( 'key1', 'key2', ... ); $judy->remove( 'key1', 'key2', ... ); # remove all entries $judy->clear; # as above $judy->search( ... );
No exports.
The Judy Array project page: http://judy.sourceforge.net/
Benjamin Holzman, <bholzman@earthlink.net<gt>
Copyright (C) 2005-2009 by Benjamin Holzman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
To install Tie::Judy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Judy
CPAN shell
perl -MCPAN -e shell install Tie::Judy
For more information on module installation, please visit the detailed CPAN module installation guide.