The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Perl::Critic::Policy::Subroutines::ProhibitQualifiedSubDeclarations

AFFILIATION

This policy is part of Perl::Critic::StricterSubs.

DESCRIPTION

Perl permits you to declare subroutines into any package that you want. This can be downright dangerous if that package is already defined elsewhere.

package Foo;

sub Bar::frobulate {}  #not ok
sub frobulate {}       #ok

Even if you declare a subroutine into the current package, using a fully-qualified name is just weird.

package  Foo;

sub Foo::frobulate {} #not ok
sub frobulate {}      #ok

So this Policy catches any subroutine declaration that contains "::" in the subroutine's name.

CAVEATS

Overriding subroutines in other packages is a common testing technique. So you may want to disable this policy when critiquing test scripts.

AUTHOR

Jeffrey Ryan Thalhammer <thaljef@cpan.org>

COPYRIGHT

Copyright 2007-2024 Jeffrey Ryan Thalhammer and Andy Lester