Mojolic...Pattern(3)
β¨ NAME β¨
okay bestie, this is the Mojolic...Pattern(3) page from the User Contributed Perl Documentation β aka Mojolicious::Routes::Pattern, the Route pattern module. π
πΈ SYNOPSIS πΈ
use Mojolicious::Routes::Pattern;
# Create pattern
my $pattern = Mojolicious::Routes::Pattern->new('/test/:name');
# Match routes
my $captures = $pattern->match('/test/sebastian');
say $captures->{name};
π DESCRIPTION π
Mojolicious::Routes::Pattern is literally the core of Mojolicious::Routes. main character energy fr fr. π
π ATTRIBUTES π
Mojolicious::Routes::Pattern implements these attributes, bestie:
constraints
my $constraints = $pattern->constraints;
$pattern = $pattern->constraints({foo => qr/\w+/});
These are your regular expression constraints β the lil regex rules for whatβs allowed. β¨
defaults
my $defaults = $pattern->defaults;
$pattern = $pattern->defaults({foo => 'bar'});
Default parameters. The fallback cuties. π
placeholder_start
my $start = $pattern->placeholder_start;
$pattern = $pattern->placeholder_start(':');
The character that indicates a placeholder; defaults to ":". π
placeholders
my $placeholders = $pattern->placeholders;
$pattern = $pattern->placeholders(['foo', 'bar']);
Placeholder names. Iconic list behavior. π
quote_end
my $end = $pattern->quote_end;
$pattern = $pattern->quote_end('}');
The character that indicates the end of a quoted placeholder; defaults to ">". β¨
quote_start
my $start = $pattern->quote_start;
$pattern = $pattern->quote_start('{');
The character that indicates the start of a quoted placeholder; defaults to "<". π«Ά
regex
my $regex = $pattern->regex;
$pattern = $pattern->regex($regex);
Your pattern in compiled regular expression form. regex girlie slay. π₯
relaxed_start
my $start = $pattern->relaxed_start;
$pattern = $pattern->relaxed_start('*');
The character that indicates a relaxed placeholder; defaults to "#". πΈ
tree
my $tree = $pattern->tree;
$pattern = $pattern->tree([['text', '/foo']]);
Your pattern in parsed form. π
β οΈ Warning bestie: this structure should only be used very carefully, since it is very dynamic. Respect the chaos. π
type_start
my $start = $pattern->type_start;
$pattern = $pattern->type_start('|');
The character that indicates the start of a placeholder type; defaults to ":". π¦
types
my $types = $pattern->types;
$pattern = $pattern->types({int => qr/[0-9]+/});
Placeholder types. Categorize the girlies. π
unparsed
my $unparsed = $pattern->unparsed;
$pattern = $pattern->unparsed('/:foo/:bar');
Raw unparsed pattern. The before pic. πΈ
wildcard_start
my $start = $pattern->wildcard_start;
$pattern = $pattern->wildcard_start('*');
The character that indicates the start of a wildcard placeholder; defaults to "*". π
π₯ METHODS π₯
Mojolicious::Routes::Pattern inherits all methods from Mojo::Base and implements these new ones:
match
my $captures = $pattern->match('/foo/bar');
my $captures = $pattern->match('/foo/bar', 1);
Match the pattern against the entire path. Format detection is disabled by default. The example also shows the 1 variant, iykyk. π
match_partial
my $captures = $pattern->match_partial(\$path);
my $captures = $pattern->match_partial(\$path, 1);
Match the pattern against the path and remove the matching parts. Format detection is disabled by default. βοΈ
new
my $pattern = Mojolicious::Routes::Pattern->new;
my $pattern = Mojolicious::Routes::Pattern->new('/users/:id');
my $pattern = Mojolicious::Routes::Pattern->new('/user/:id', id => qr/\d+/);
my $pattern = Mojolicious::Routes::Pattern->new(format => ['json', 'yaml']);
Construct a new Mojolicious::Routes::Pattern object and βparseβ the pattern if necessary. Fresh object, fresh vibes. β¨
parse
$pattern = $pattern->parse('/user/:id');
$pattern = $pattern->parse('/user/:id', id=> qr/\d+/);
$pattern = $pattern->parse(format => ['json', 'yaml']);
Parse pattern. Do the parsing thing. π§
render
my $path = $pattern->render({id => 24});
my $path = $pattern->render({id => 24}, 1);
Render the pattern into a path with parameters. Format rendering is disabled by default. The second example passes 1. π
π¦ SEE ALSO π¦
MojoliciousMojolicious::Guides- <https://mojolicious.org>
Sign-off time, bestie: this cutie page comes from source/version perl v5.42.0, dated 2026-07-15, and itβs the Mojolic...Pattern(3) manual page. Bye bestie, go route something iconic! π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms