Perl::...::Block(3pm)
π NAME π
Perl::Tidy::Sweetened::Keyword::Block β it's the Perl::Tidy::Sweetened filter plugin that lets you define your own new sub and class keywords. Bestie. That's the whole vibe. (Also it lives at Perl::...::Block(3pm) in the man pages, that's just the nickname the manual gives it, okay??) π¦
β¨ VERSION β¨
version 1.20 πΈ
π SYNOPSIS π
our $plugins = Perl::Tidy::Sweetened::Pluggable->new();
$plugins->add_filter(
Perl::Tidy::Sweetened::Keyword::Block->new(
keyword => 'method',
marker => 'METHOD',
replacement => 'sub',
clauses => [ 'PAREN?', '(returns \s* PAREN)?' ],
) );
π DESCRIPTION π
Okay so this is a Perl::Tidy::Sweetened filter, and what it does is enable the definition of arbitrary keywords for subroutines, with any number of potential signature definitions. Yes, any number. We're not gatekeeping. π
Here's what new takes, bestie, one by one:
keyword
keyword => 'method'
Declares a new keyword β in this example it's the method keyword. It's giving main character energy, honestly. β
marker
marker => 'METHOD'
This gives you a text marker that gets used to flag your new keywords during prefilter. The source code gets filtered before formatting by Perl::Tidy, so that:
method foo {
}
gets turned into:
sub foo { # __METHOD 1
}
Lowkey obsessed with that transformation, no cap. π
replacement
replacement => 'sub'
Will convert the keyword to a sub as shown above. That's it, that's the job. π«Ά
clauses
clauses => [ 'PAREN?' ]
Provides a list of strings which will be turned into a regex to capture additional clauses. Heads up: the regex will include the xm flags, so be sure to escape spaces. A clause can be marked optional with ?. And the special text PAREN can be used to capture a balanced parenthetical. π«
This example will capture a parameter list enclosed by parenthesis, ie:
method foo (Int $i) {
}
No formatting is done on the clauses at this time. And the order of declaration is significant. The order. Is. Significant. π
π AUTHOR π
Mark Grimes <mgrimes@cpan.org> π
π SOURCE π
Source repository is at <https://github.com/mvgrimes/Perl-Tidy-Sweetened>.
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://github.com/mvgrimes/Perl-Tidy-Sweetened/issues>
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. (fr fr, the maintainers will love you for it, that's the real slay β¨)
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2023 by Mark Grimes <mgrimes@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
And that's a wrap, bestie π this page was served up by perl v5.36.0 on 2023-06-18, and yeah, the header says Perl::...::Block(3pm) but you and I both know her full government name. Periodt. π
π¦ where this page comes from
- debian trixie: perltidier 1.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: perltidier 1.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: perltidier 1.20-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms