perlmeditation
vitoco
<p>I needed a simple way to test if a list of keywords (tags) had the required words, but one moment later, conditional operators other than AND were required. I didn't find a public module that satisfied my needs. Some of this was discussed in [id://791083].</p>
<p>I took my subs and group them in a module, then changed into objects (my first attempt in OOP) and worked nice.</p>
<readmore>
<p>Examples of use:</p>
<code>
# Simple query (same as: +xxx -ppp -jjj):
my $query = "xxx-(ppp,jjj)";
use Keywords;
my $kw = Keywords->new(ignorecase => 1);
$kw->prepare($query);
# Simple test:
print "Match!" if $kw->test($list_of_tags);
# @ids has some keys %table:
@ok = grep {$kw->test($table{$_}[$col])} @ids;
# Same as before:
@ok = $kw->grep_keys(map {$_ => $table{$_}[$col]} @ids);
# Hash only has keywords lists:
@ok = $kw->grep_keys(%tags);
# When ids are full keywords:
@ok = $kw->grep(@ids);
</code>
</readmore>
<p>Now, I want to share my efforts and decided to upload this to CPAN, but I need to define or append to a namespace. I thought on <b>Search::Keywords</b>, but <b>Keywords::Match</b> might be a better one.</p>
<p>Hints for a proper namespace?</p>
<p>Hints for extra features? I'm thinking on set/get parms, reparse, sentences (when tags have more than one word), UTF8 (un)support...</p>
<p>Thanks!</p>