Text::...Numbers(3pm)
π Text::MicroMason::LineNumbers π
okay bestie, this is the User Contributed Perl Documentation page for Text::MicroMason::LineNumbers (that's the 3pm one, you know the vibe β¨).
β¨ NAME β¨
Text::MicroMason::LineNumbers β no cap, its whole job is reporting errors at the correct source code line numbers. π―
πΈ DESCRIPTION πΈ
So this is a mixin class (iykyk) and what it does is associate every single token in a template with the line number where it was found. Then it inserts special comments into the generated Perl code that preserve that original source file + line number info. π¦
It's giving debugging glow-up, fr fr β it makes it so much easier to match up runtime errors with the actual template code that produced them. ππ
To turn this behavior on, just add -LineNumbers to your MicroMason creation call:
my $mason = Text::MicroMason->new( qw( -LineNumbers ) );
π Public Methods π
These methods get called from within the normal flow of MicroMason functionality, so you do not need to invoke them directly. They're just doing their thing backstage. π
read()β Clears the variables used to store the file name and first line of a template, so that they can be set by the methods below. Wiping the slate clean, periodt. π§read_file()β Saves the source file name before invoking the standard behavior for this method.
$mason->compile( file => $filename );
read_handle()β Saves the caller's file name before invoking the standard behavior for this method.
$mason->compile( handle => $filename );
read_text()β Saves the caller's file name before invoking the standard behavior for this method.
$mason->compile( text => $filename );
read_inline()β This one's similar toread_text, except it adjusts the line numbering to reflect a template that's embedded as a literal text in the Perl code. Sneaky but iconic. π
$mason->compile( inline => q{
My template text goes here.
} );
lex()β Identical to thelex()method provided by the Base class, except that it also inserts a stream of line-number-setting comments into the to-be-compiled Perl code that attempt to re-synchronize theassembler_rules()β Maps theline_numtoken to a perl line number comment. π«
π Private Methods π
_get_external_caller()β Returns the source file and line number of the first item in the function call stack that is not aText::MicroMasonpackage. Lowkey the detective of the whole operation. π
π SEE ALSO π
- For an overview of this templating framework, see
Text::MicroMason. - This is a mixin class intended for use with
Text::MicroMason::Base. π«Ά - For distribution, installation, support, copyright and license information, see
Text::MicroMason::Docs::ReadMe. π
heads up bestie, the lex() description above really does trail off mid-sentence like that. I'm not fixing it, I'm not guessing the rest β I'm just reporting what's on the page. π
and that's the whole thing!! this page is from perl v5.36.0, dated 2023-08-10, and it's part of the Text::...Numbers(3pm) manual. mwah, slay, go forth and debug with accurate line numbers β¨π
π¦ where this page comes from
- debian trixie: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtext-micromason-perl 2.23-5 Β· 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