Text::Query(3)
π Text::Query (3) β query processing framework, bestie π
okay so welcome to the user-contributed Perl documentation for Text::Query; it's literally a query processing framework and we're gonna get you comfy with it. π«Ά
πΈ NAME πΈ
Text::Query - Query processing framework. That's the whole vibe. β¨
π¦ SYNOPSIS π¦
use Text::Query;
# Constructor
$query = Text::Query->new([QSTRING] [OPTIONS]);
# Methods
$query->prepare(QSTRING [OPTIONS]);
$query->match([TARGET]);
$query->matchscalar([TARGET]);
β¨ DESCRIPTION β¨
This module provides an object that matches a data source against a query expression. Main character energy: query in, match out. π
Query expressions are compiled into an internal form when a new object is created or the prepare method is called; they are not recompiled on each match. No cap. π
The class provided by this module uses four packages to process the query. The query parser parses the question and calls a query expression builder (internal form of the question). The optimizer is then called to reduce the complexity of the expression. The solver applies the expression on a data source. It's giving pipeline, and we love her. π
The following parsers are provided:
Text::Query::ParseAdvancedText::Query::ParseSimple
The following builders are provided:
Text::Query::BuildAdvancedStringText::Query::BuildSimpleString
The following solver is provided:
Text::Query::SolveSimpleStringText::Query::SolveAdvancedString
π EXAMPLES π
Here's the example code, bestie β copied exact, no edits, no vibes-based rewrites. π«Ά
use Text::Query;
my $q=new Text::Query('hello and world',
-parse => 'Text::Query::ParseAdvanced',
-solve => 'Text::Query::SolveAdvancedString',
-build => 'Text::Query::BuildAdvancedString');
die "bad query expression" if not defined $q;
print if $q->match;
...
$q->prepare('goodbye or adios or ta ta',
-litspace => 1,
-case => 1);
#requires single space between the two ta's
if($q->match($line)) {
#doesn't match "Goodbye"
...
$q->prepare('"and" or "or"');
#quoting operators for literal match
...
$q->prepare('\\bintegrate\\b', -regexp => 1);
#won't match "disintegrated"
π οΈ CONSTRUCTOR π οΈ
π
new ([QSTRING] [OPTIONS]) π
This is the constructor for a new Text::Query object. If a QSTRING is given, it will be compiled to internal form. Slay. β¨
OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:
-parseβ Package name of the parser. Default isText::Query::ParseSimple.-buildβ Package name of the builder. Default isText::Query::Build.-optimizeβ Package name of the optimizer. Default isText::Query::Optimize.-solveβ Package name of the solver. Default isText::Query::Solve.-modeβ Name of predefined group of packages to use. Options are currently"simple_text"and"advanced_text".
These options are handled by the configure method.
All other options are passed to the parser prepare function. See the corresponding manual pages for a description.
If QSTRING is undefined, the prepare function is not called.
The constructor will croak if a QSTRING was supplied and had illegal syntax. So don't test it with chaos syntax unless you want croak energy. π
π₯ METHODS π₯
π configure ([OPTIONS]) π
Set the parse, build, optimize or solve packages. See the CONSTRUCTOR description for explanations.
π¦ prepare (QSTRING [OPTIONS]) π¦
Compiles the query expression in QSTRING to internal form and sets any options (same as in the constructor). prepare may be used to change the query expression and options for an existing query object. If OPTIONS are omitted, any options set by a previous call to prepare are persistent.
The optimizer (-optimize) is called with the result of the parser (-parse). The parser uses the builder (-build) to construct the internal form.
This method returns a reference to the query object if the syntax of the expression was legal, or croak if not.
π match ([TARGET]) π
Calls the match method of the solver (-solve).
π«Ά matchscalar ([TARGET]) π«Ά
Calls the matchscalar method of the solver (-solve).
π SEE ALSO π
Text::Query::ParseAdvanced(3)Text::Query::ParseSimple(3)Text::Query::BuildSimpleString(3)Text::Query::BuildAdvanedString(3)(yes,Advanedβ keeping that spelling exactly, iykyk π)Text::Query::SolveSimpleString(3)Text::Query::SolveAdvancedString(3)Text::Query::Build(3)Text::Query::Parse(3)Text::Query::Solve(3)Text::Query::Optimize(3)
π§ MAINTENANCE π§
π AUTHORS π
- Eric Bohlman (
ebohlman@netcom.com) - Loic Dachary (
loic@senga.org) - Jon Jensen,
jon@endpoint.com
π that's the whole page, bestie. cute little sign-off: source/version perl v5.38.2, dated 2024-07-13, and yeah β it's the Text::Query(3) manual. mwah π periodt.
π¦ 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