1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/Variables/ProhibitPerl4PackageNames.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames;
15 use Perl::Critic::Utils qw{ :characters :severities :classification };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $EXPL =>
23 q{Use double colon (::) to separate package name components instead of single quotes (')};
25 #-----------------------------------------------------------------------------
27 sub supported_parameters { return () }
28 sub default_severity { return $SEVERITY_LOW }
29 sub default_themes { return qw(core maintenance) }
30 sub applies_to { return qw( PPI::Token::Word PPI::Token::Symbol ) }
32 #-----------------------------------------------------------------------------
35 my ( $self, $elem, undef ) = @_;
36 my $content = $elem->content();
38 if ( (index $content, $QUOTE) < 0 ) {
42 if ( $content =~ m< \A [\$@%&*] ' \z >xms ) {
43 # We've found $POSTMATCH.
47 if ( $elem->isa('PPI::Token::Word') && is_hash_key($elem) ) {
53 qq{"$content" uses the obsolete single quote package separator."},
59 #-----------------------------------------------------------------------------
65 #-----------------------------------------------------------------------------
71 Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames - Use double colon (::) to separate package name components instead of single quotes (').
75 This Policy is part of the core L<Perl::Critic> distribution.
80 Perl 5 kept single quotes (C<'>) as package component separators in
81 order to remain backward compatible with prior C<perl>s, but advocated
82 using double colon (C<::>) instead. In the more than a decade since
83 Perl 5, double colons have been overwhelmingly adopted and most people
84 are not even aware that the single quote can be used in this manner.
85 So, unless you're trying to obfuscate your code, don't use them.
87 package Foo::Bar::Baz; #ok
88 package Foo'Bar'Baz; #not ok
93 This Policy is not configurable except for the standard options.
102 Elliot Shank C<< <perl@galumph.com> >>
106 Copyright (c) 2007-2008 Elliot Shank. All rights reserved.
108 This program is free software; you can redistribute it and/or modify
109 it under the same terms as Perl itself. The full text of this license
110 can be found in the LICENSE file included with this module.
116 # cperl-indent-level: 4
118 # indent-tabs-mode: nil
119 # c-indentation-style: bsd
121 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :