Perl::...monyms(3pm)
π NAME π
Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms β okay so basically: do NOT declare your own open function, bestie. That's the whole vibe. π«
(this lil page lives in the Perl::...monyms(3pm) manpage section, iykyk)
π AFFILIATION π
This Policy is part of the core Perl::Critic distribution. She's iconic, she ships with the whole thing. π
β¨ DESCRIPTION β¨
So like. Common sense literally dictates that you shouldn't declare subroutines with the same name as one of Perl's built-in functions or keywords. It's giving "why would you do that to yourself." π
- Wanna see the built-in functions? Check
perlfunc. - Wanna see the keywords? Check
perlsyn.
Now look at these crimes against humanity:
sub open {} #not ok
sub exit {} #not ok
sub print {} #not ok
sub foreach {} #not ok
sub if {} #not ok
#You get the idea...
Not ok. Not one of them. Ngl every single one of these is a red flag π© and the policy will come for them.
BUT β and this is the good part β exceptions are made for BEGIN, END, INIT and CHECK blocks, as well as AUTOLOAD, DESTROY, and import subroutines. Those ones ate and left no crumbs. π«Ά
πΈ CONFIGURATION πΈ
You can configure additional builtin homonyms to accept by specifying them in a space-delimited list to the allow option:
[Subroutines::ProhibitBuiltinHomonyms]
allow = default index
These are added to the default list of exemptions from this policy. So the above allows sub default {} and sub index {}. Slay, she's flexible. β¨
π CAVEATS π
It is reasonable to declare an object method with the same name as a Perl built-in function, since they are easily distinguished from each other. Like, fair, we get it, method call syntax is different, no cap.
However β and this is the tragic part π β at this time, Perl::Critic cannot tell whether a subroutine is static or an object method. So she's out here judging everyone equally. It's not personal, it's just policy. π
π¦ AUTHOR π¦
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
π COPYRIGHT π
Copyright (c) 2005-2022 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.
And that's the page, bestie! π This was perl v5.42.0, dated 2024-10-23, and you read it in Perl::...monyms(3pm). Go forth and don't name your sub print. ππ¦β¨
π¦ 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