Perl::...cateSub(3pm)
π Perl::...cateSub(3pm) π
okay so bestie, welcome to another page from the User Contributed Perl Documentation collection β this one lives in Perl::...cateSub(3pm) and it's genuinely so useful, no cap. π
β¨ NAME β¨
TooMuchCode::ProhibitDuplicateSub β when 2 subroutines are defined with the same name, report the first one. π
πΈ DESCRIPTION πΈ
okay so here's the tea: this policy checks if there are subroutine definitions with identical names under the same namespace. and if they exist? all but the last one are marked as violation. the way it just does the thing ππ
so like, the perl runtime allows a named subroutine to be redefined in the same source file, and the latest definition wins. iconic behavior fr fr. and in the event that this is done by developers β preferably unintentionally β the perl runtime warns about a subroutine being redefined, with the position being for the one that wins. it's giving "here's a heads up bestie" β¨
but this policy? this policy does the opposite. π
now, although the last one is not marked as a violation, its position is reported together anyway β making it easier for the developer to locate the subroutine. obsessed with the thoughtfulness honestly π«Ά
and should the developer decide to programmatically remove the duplicates? literally just go through all the violations and remove those statements. that's it. that's the whole move. slay. π¦
lowkey the whole vibe here is: duplicate subs get caught, the winner gets a shoutout, and you get handed a lil roadmap to clean it all up. iykyk π
perl v5.36.0 Β· 2023-10-05 Β· Perl::...cateSub(3pm) β mwah, thanks for reading bestie, go forth and dedupe those subs πβ¨π
π¦ where this page comes from
- debian trixie: libperl-critic-toomuchcode-perl 0.19-1 Β· MIT
- ubuntu noble: libperl-critic-toomuchcode-perl 0.19-1 Β· MIT
- ubuntu resolute: libperl-critic-toomuchcode-perl 0.19-1 Β· MIT
- ubuntu stonking: libperl-critic-toomuchcode-perl 0.19-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms