Perl::...rations(3pm)
β¨ NAME β¨
Okay bestie, gather round π the page you just pulled up is Perl::...rations(3pm), and the actual star of the show β the policy living inside it β is Perl::Critic::Policy::Subroutines::ProhibitQualifiedSubDeclarations. Say that five times fast, I dare you. π«Ά
πΈ AFFILIATION πΈ
This policy is part of Perl::Critic::StricterSubs. It's giving "I have a very specific job and I do it well." π
π¦ DESCRIPTION π¦
So here's the tea β Perl literally lets you declare subroutines into any package you want. Any. Package. Which is iconic in a "chaos demon" way, because if that package is already defined somewhere else? Yeah. That's downright dangerous. π
Look at this:
package Foo;
sub Bar::frobulate {} #not ok
sub frobulate {} #ok
You see that? Reaching into Bar from inside Foo? Not ok. Very much not ok. π«
And honestly, even if you're declaring a subroutine into your own current package, using a fully-qualified name is justβ¦ weird. Like showing up to your own birthday party in formal wear. π
package Foo;
sub Foo::frobulate {} #not ok
sub frobulate {} #ok
Same package, still not it. π
So this Policy catches any subroutine declaration that contains :: in the subroutine's name. Every single one. No cap. It's a vibe check on your sub names and honestly? It ate. π
β οΈ CAVEATS β οΈ
Okay so real talk, bestie π overriding subroutines in other packages is a common testing technique. It's a whole thing people do on purpose. So you may want to disable this policy when critiquing test scripts, because otherwise it will absolutely come for your test files and you will be sad. π Not a bug, just a lifestyle conflict. π
π AUTHOR π
Jeffrey Ryan Thalhammer <thaljef@cpan.org> β legend behavior, fr fr. π
π COPYRIGHT π
Copyright 2007-2024 Jeffrey Ryan Thalhammer and Andy Lester
And that's a wrap, bestie β¨ this was pulled from perl v5.42.0, dated 2025-07-25, filed under that Perl::...rations(3pm) manual page name. Go forth and declare your subs unqualified, mwah π π¦πΈ
π¦ where this page comes from
- fedora 43: perl-Perl-Critic-StricterSubs 0.08-3.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms