Perl::...tedSubs(3pm)
β¨ NAME β¨
Perl::Critic::Policy::Subroutines::ProhibitNestedSubs β literally "sub never { sub correct {} }". Thatβs the whole vibe.
This lilβ Perl::...tedSubs(3pm) page comes from the User Contributed Perl Documentation, and itβs here to save you from a very specific Perl heartbreak. π
πΈ AFFILIATION πΈ
This Policy is part of the core Perl::Critic distribution. Sheβs core, bestie. π
π DESCRIPTION π
Okay so, attention would-be clever Perl writers (including Younger RJBS π):
This does not do what you think:
sub do_something {
...
sub do_subprocess {
...
}
...
}
The way that do_subprocess() is global despite where it is declared is lowkey giving main-character plot twist. Either write your subs without nesting or use anonymous code references. Periodt. π₯
π CONFIGURATION π
This Policy is not configurable except for the standard options. No extra knobs, no secret settings, no little config treats. Thatβs it. π
π¦ NOTE π¦
Fun fact: this policy was originally part of Perl::Critic::Tics. Iconic origin story, honestly. β¨
π AUTHOR π
Ricardo SIGNES <rjbs@cpan.org> β the legend who wrote this. π«Ά
π COPYRIGHT π
Copyright (c) 2007-2011 Ricardo SIGNES.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Mwah π β thatβs the whole Perl::...tedSubs(3pm) page, from perl v5.42.0, dated 2024-10-23. Go forth and donβt nest your subs, bestie. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms