Login
Added svn keywords.
[gknop/Perl-Critic.git] / lib / Perl / Critic / Policy / BuiltinFunctions / RequireGlobFunction.pm
CommitLineData
34167feb
JRT
1##################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##################################################################
7
59b05e08
JRT
8package Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction;
9
10use strict;
11use warnings;
12use Perl::Critic::Utils;
13use Perl::Critic::Violation;
14use base 'Perl::Critic::Policy';
15
16our $VERSION = '0.13';
17$VERSION = eval $VERSION; ## no critic
18
19my $glob_rx = qr{ [\*\?] }x;
20my $desc = q{Glob written as <...>};
21my $expl = [167];
22
23#----------------------------------------------------------------------------
24
25sub violates {
26 my ( $self, $elem, $doc ) = @_;
27 $elem->isa('PPI::Token::QuoteLike::Readline') || return;
28 if ( $elem =~ $glob_rx ) {
29 return Perl::Critic::Violation->new( $desc, $expl, $elem->location() );
30 }
31 return; #ok!
32}
33
341;
35
36__END__
37
38=head1 NAME
39
40Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction
41
42=head1 DESCRIPTION
43
44Conway discourages the use of the C<E<lt>..E<gt>> construct for globbing, as
45its heavily associated with I/O in most people's minds. Instead, he recommends
46the use of the C<glob()> function as it makes it much more obvious what you're
47attempting to do.
48
49 @files = <*.pl>; # not ok
50 @files = glob( "*.pl" ); # ok
51
52=head1 AUTHOR
53
54Graham TerMarsch <graham@howlingfrog.com>
55
56Copyright (C) 2005 Graham TerMarsch. All rights reserved.
57
58This program is free software; you can redistribute it and/or modify
59it under the same terms as Perl itself.