Perl::...rations(3pm)

πŸ“¦
version 0.08 Β· 2 versions
, in fedora 43

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