Mason:...:Setup(3pm)
π Mason:...:Setup(3pm) β like, the setup manual bestie π
User Contributed Perl Documentation β¨ okay so this is Mason::Manual::Setup, and it's literally just called Setting up Mason. Buckle up, we're installing vibes.
πΈ NAME πΈ
Mason::Manual::Setup β setting up Mason π
β¨ SETUP β¨
π¦ Web development π¦
The most common use of Mason is to generate dynamic web content, and honestly? That's its whole main character moment.
Poet is a web framework designed specifically to work with Mason. Given an HTTP request, Poet generates a corresponding Mason request, and uses the output from Mason to form the HTTP response. Poet takes care of the web development details that are outside of Mason's domain β stuff like server integration and configuration. Poet::Manual::Tutorial shows how to set up a Poet/Mason site in great detail, so go read that if you want the full step-by-step.
Mason can also be used in the popular web frameworks Catalyst and Dancer, as a drop-in replacement for their default template engines. See Catalyst::View::Mason2 and Dancer::Template::Mason2. Slay π
π§ Non-web development π§
Mason can be used to generate any kind of dynamic content, not just websites. The author has personally used it to generate Apache configuration files, emails, and C++ code. Yes bestie, C++ code. Range.
To use Mason from a script or library, use the Mason::Interp API:
my $interp = Mason->new(
comp_root => '/path/to/comps',
data_dir => '/path/to/data',
...
);
my $output = $interp->run( '/request/path', foo => 5 )->output();
If you want to process a directory with a mix of Mason templates and static files, check out Any::Template::ProcessDir. It's giving exactly what you need π«Ά
Wanna try out Mason syntax straight from the command line? Use the mason script:
% mason
2 + 2 = <% 2+2 %>
^D
2 + 2 = 4
Not me casually getting 4 back π iconic behaviour fr fr.
π LOGGING π
Mason uses Log::Any to log various events, such as the start and end of each request. You can direct these logs to the output of your choice β see Log::Any::Adapter. If you don't specify anything, then the logs will go into the void. π³οΈ Just gone. No thoughts, head empty.
β SEE ALSO β
Mason
π AUTHOR π
Jonathan Swartz <swartz@pobox.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2012 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
That's the whole page bestie β brought to you by perl v5.34.0, dated 2022-05-27, under the Mason:...:Setup(3pm) banner from the User Contributed Perl Documentation crew. Go set something up, you've got this πβ¨π
π¦ where this page comes from
- debian bookworm: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms