Risk-Aware AI Code Review for Business-Critical Systems
LiveReview LiveReview Explore LiveReview

Perl::Critic::Policy::Subroutines::ProhibitNestedSubs - "sub never { sub correct {} }".

Affiliation

       This Policy is part of the core Perl::Critic distribution.

Author

       Ricardo SIGNES <rjbs@cpan.org>

Configuration

       This Policy is not configurable except for the standard options.

Description

Attentionwould-becleverPerlwriters(includingYoungerRJBS):

       This does not do what you think:

         sub do_something {
             ...
             sub do_subprocess {
                 ...
             }
             ...
         }

       do_subprocess() is global, despite where it is declared.  Either write your subs without nesting or use
       anonymous code references.

Name

       Perl::Critic::Policy::Subroutines::ProhibitNestedSubs - "sub never { sub correct {} }".

Note

       Originally part of Perl::Critic::Tics.

See Also