This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update version to 0.9916
[perl5.git] / cpan / version / lib / version.pm
CommitLineData
c8d69e4a 1#!perl -w
a7ad731c
HS
2package version;
3
05402f6b 4use 5.006002;
a7ad731c 5use strict;
14f3031b
JP
6use warnings::register;
7if ($] >= 5.015) {
8 warnings::register_categories(qw/version/);
9}
a7ad731c 10
effa684c 11use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
a7ad731c 12
3462bde7 13$VERSION = 0.9916;
a7ad731c
HS
14$CLASS = 'version';
15
16885730 16# avoid using Exporter
0a24517e 17require version::regex;
16885730
JP
18*version::is_lax = \&version::regex::is_lax;
19*version::is_strict = \&version::regex::is_strict;
db9cb848
JP
20*LAX = \$version::regex::LAX;
21*STRICT = \$version::regex::STRICT;
91152fc1 22
c8a14fb6 23sub import {
c8a14fb6 24 no strict 'refs';
f941e658
JP
25 my ($class) = shift;
26
27 # Set up any derived class
4141ef59 28 unless ($class eq $CLASS) {
f941e658 29 local $^W;
4141ef59
JP
30 *{$class.'::declare'} = \&{$CLASS.'::declare'};
31 *{$class.'::qv'} = \&{$CLASS.'::qv'};
f941e658
JP
32 }
33
34 my %args;
35 if (@_) { # any remaining terms are arguments
36 map { $args{$_} = 1 } @_
37 }
38 else { # no parameters at all on use line
5027b3af 39 %args =
f941e658
JP
40 (
41 qv => 1,
42 'UNIVERSAL::VERSION' => 1,
43 );
44 }
91152fc1 45
f941e658 46 my $callpkg = caller();
5027b3af 47
f941e658 48 if (exists($args{declare})) {
5027b3af 49 *{$callpkg.'::declare'} =
f941e658
JP
50 sub {return $class->declare(shift) }
51 unless defined(&{$callpkg.'::declare'});
52 }
53
54 if (exists($args{qv})) {
61a0cb1c 55 *{$callpkg.'::qv'} =
f941e658 56 sub {return $class->qv(shift) }
61a0cb1c 57 unless defined(&{$callpkg.'::qv'});
f941e658 58 }
c0b17f21 59
4141ef59
JP
60 if (exists($args{'UNIVERSAL::VERSION'})) {
61 local $^W;
62 *UNIVERSAL::VERSION
63 = \&{$CLASS.'::_VERSION'};
64 }
65
f941e658 66 if (exists($args{'VERSION'})) {
4141ef59 67 *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'};
61a0cb1c
JP
68 }
69
70 if (exists($args{'is_strict'})) {
4141ef59 71 *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'}
d54f8cf7 72 unless defined(&{$callpkg.'::is_strict'});
61a0cb1c
JP
73 }
74
75 if (exists($args{'is_lax'})) {
4141ef59 76 *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'}
d54f8cf7 77 unless defined(&{$callpkg.'::is_lax'});
f941e658 78 }
c8a14fb6 79}
a7ad731c 80
91152fc1 81
a7ad731c 821;