Tie::Hash::Approx - Approximative match of hash keys using String::Approx
use Tie::Hash::Approx; my %hash; tie %hash, 'Tie::Hash::Approx'; %hash = ( key => 'value', kay => 'another value', stuff => 'yet another stuff', ); print $hash{'key'}; # prints 'value' print $hash{'koy'}; # prints 'another value' or 'value' print $hash{'staff'}; # prints 'yet another stuff' print tied(%hash)->FETCH('koy'); # prints 'value' and 'another value' delete $hash{kee}; # deletes $h{key} and $h{kay}
Following the idea of Tie::Hash::Regex, this module is an attempt to make fuzzy matches on hash keys. The module first tries to fetch the exact key of the hash, and failing that, the key is passed to the String::Approx' amatch function. Note that you can't (yet) pass modifiers to amatch.
amatch
To fetch multiple matching keys, you'll have to use something like:
@all_matches = tied(%h)->FETCH('the key');
Note also the deleting a hash key will delete all the approximate matches, unless you provide the exact match of the key.
Specify the "fuzziness" of the match (cf. the modifiers option in String::Approx).
Briac Pilpre < briac @ pilpre . com >
Thanks to Dave Cross for making Tie::Hash::Regex in the first place!
Copyright 2001, Briac Pilpré. All Rights Reserved. This module can be redistributed under the same terms as Perl itself.
perl(1). perltie(1). Tie::Hash. String::Approx
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Pilpré.'. Assuming CP1252
To install Tie::Hash::Approx, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Hash::Approx
CPAN shell
perl -MCPAN -e shell install Tie::Hash::Approx
For more information on module installation, please visit the detailed CPAN module installation guide.