Text::Q...dvanced(3)
β¨ Text::Query::ParseAdvanced β parse AltaVista advanced query syntax, bestie β¨
Okay so this is the Text::Query::ParseAdvanced(3) page from the User Contributed Perl Documentation, and honestly? It's giving parser-girl summer. Let's get into it π
πΈ SYNOPSIS πΈ
Standard little setup moment β load the module and build your query object:
use Text::Query;
my $q=new Text::Query('hello and world',
-parse => 'Text::Query::ParseAdvanced',
-solve => 'Text::Query::SolveAdvancedString',
-build => 'Text::Query::BuildAdvancedString');
Look at that trio of -parse, -solve, -build β iconic behavior, no notes π«Ά
π¦ DESCRIPTION π¦
So this module literally provides an object that parses a string containing a Boolean query expression, the kind that's similar to an AltaVista "advanced query". Very retro, very main character π
Its base class is Text::Query::Parse β that's the parent, the origin story, iykyk.
Query expressions are made of literal strings (or regexps) joined by these operators, and here they are in order of precedence, lowest to highest:
OR,|AND,&NEAR,~NOT,!
Operator names are not case-sensitive, so go off with your lowercase era β¨
Heads up bestie: if you want to use a|inside a regexp, you need to backwhack it (\|) so it doesn't get read as a query operator. Don't skip that part, fr fr π
Sub-expressions may be quoted in single or double quotes so you can match "and," "or," or "not" literally β yes, the words themselves, not the operators. And they may be grouped in parentheses ((, )) to alter the precedence of evaluation. Grouping = control, and control is a whole vibe π
A parenthesized sub-expression may also be concatenated with other sub-expressions to match sequences. Example that ate:
"(Perl or Python) interpreter" would match either "Perl interpreter" or "Python interpreter".
Concatenation has a precedence higher than NOT but lower than AND. Juxtaposition of simple words has the highest precedence of all β literally the top of the food chain, periodt π
π OPTIONS π
These are the additional options of the prepare method and the constructor, bestie β the little extras you can pass in:
-nearβ defaults to10. Sets the number of words that can occur between two expressions and still satisfy theNEARoperator. Ten whole words of leeway, slay π-operatorsβ defaults toand, or, not, near. Sets the operator names. The argument of the option is a pointer to a hash table mapping the default names to desired names. For instance:
{
'or' => 'ou',
'and' => 'et',
'near' => 'proche',
'not' => 'non',
}
Oui oui, localization moment π«π·β¨
-scope_mapβ default to{}. Maps the scope names to other names. If a scope is specified as"scope:", search the map for an entry whose key is"scope"and replace"scope"with the scalar found. For instance:
{
'scope' => 'otherscope'
}
Renaming scopes? Very remix culture of you π§
π SEE ALSO π
Go read the family, they're all connected π«Ά
π AUTHORS π
The legends behind the whole thing:
- Eric Bohlman (
ebohlman@netcom.com) - Loic Dachary (
loic@senga.org) - Jon Jensen,
jon@endpoint.com
β¨ Cute little sign-off: this page is fromperl v5.38.2, dated2024-07-13β so go forth, parse your advanced queries, and remember: no cap, keep every backslash where it belongs π πΈπ
π¦ where this page comes from
- arch rolling: perl-text-query 0.09-5 Β· GPL AND PerlArtistic
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms