1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/BuiltinFunctions/RequireGlobFunction.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction;
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $GLOB_RX => qr{ [*?] }mx;
23 Readonly::Scalar my $DESC => q{Glob written as <...>};
24 Readonly::Scalar my $EXPL => [ 167 ];
26 #-----------------------------------------------------------------------------
28 sub supported_parameters { return () }
29 sub default_severity { return $SEVERITY_HIGHEST }
30 sub default_themes { return qw( core pbp bugs ) }
31 sub applies_to { return 'PPI::Token::QuoteLike::Readline' }
33 #-----------------------------------------------------------------------------
36 my ( $self, $elem, undef ) = @_;
38 if ( $elem =~ $GLOB_RX ) {
39 return $self->violation( $DESC, $EXPL, $elem );
48 #-----------------------------------------------------------------------------
54 Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction - Use C<glob q{*}> instead of <*>.
58 This Policy is part of the core L<Perl::Critic> distribution.
63 Conway discourages the use of the C< <..> > construct for globbing, as
64 it is easily confused with the angle bracket file input operator.
65 Instead, he recommends the use of the C<glob()> function as it makes
66 it much more obvious what you're attempting to do.
68 @files = <*.pl>; # not ok
69 @files = glob( "*.pl" ); # ok
74 This Policy is not configurable except for the standard options.
79 Graham TerMarsch <graham@howlingfrog.com>
83 Copyright (C) 2005-2007 Graham TerMarsch. All rights reserved.
85 This program is free software; you can redistribute it and/or modify
86 it under the same terms as Perl itself.
92 # cperl-indent-level: 4
94 # indent-tabs-mode: nil
95 # c-indentation-style: bsd
97 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :