1Perl::Critic::Policy::MUosdeurleCPsoe:nr:tlRr:ei:qbCuuritiretediVceP:re:srPiloolnDiVocacyru:(m:3eM)notdautlieosn::RequireVersionVar(3)
2
3
4

NAME

6       Perl::Critic::Policy::Modules::RequireVersionVar - Give every module a
7       "$VERSION" number.
8

AFFILIATION

10       This Policy is part of the core Perl::Critic distribution.
11

DESCRIPTION

13       Every Perl file (modules, libraries, and programs) should have a
14       package-scoped $VERSION variable.  The $VERSION allows clients to
15       insist on a particular revision of your file like this:
16
17           use SomeModule 2.4;  #Only loads version 2.4
18
19       This Policy scans your file for any package variable named $VERSION.
20       I'm assuming that you are using "strict", so you'll have to declare it
21       like one of these:
22
23           our $VERSION = 1.0611;
24           $MyPackage::VERSION = 1.061;
25           use vars qw($VERSION);
26           use version; our $VERSION = qv(1.0611);
27
28       Perl's version system does not recognize lexical variables such as
29
30           my $VERSION = 1.0611;
31
32       so they are not accepted by this policy.
33
34       A common practice is to use the "$Revision$" keyword to automatically
35       define the $VERSION variable like this:
36
37           our ($VERSION) = '$Revision$' =~ m{ \$Revision: \s+ (\S+) }x;
38

CONFIGURATION

40       This Policy is not configurable except for the standard options.
41

NOTES

43       Conway recommends using the "version" pragma instead of raw numbers or
44       'v-strings.'  However, this Policy only insists that the $VERSION be
45       defined somehow.  I may try to extend this in the future.
46

TO DO

48       Add check that $VERSION is independently evaluatable.  In particular,
49       prohibit this:
50
51           our $VERSION = $Other::Module::VERSION;
52
53       This doesn't work because PAUSE and other tools literally copy your
54       version declaration out of your module and evaluates it in isolation,
55       at which point there's nothing in "Other::Module", and so the $VERSION
56       is undefined.
57

AUTHOR

59       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
60
62       Copyright (c) 2005-2011 Imaginative Software Systems.  All rights
63       reserved.
64
65       This program is free software; you can redistribute it and/or modify it
66       under the same terms as Perl itself.  The full text of this license can
67       be found in the LICENSE file included with this module.
68
69
70
71perl v5.32.0               Perl::C2r0i2t0i-c0:7:-P2o8licy::Modules::RequireVersionVar(3)
Impressum