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 (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