This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test that for's iterator aliases the iterated list
[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
ff6af44f 11our $VERSION = 0.9929;
a6842133
JP
12our $CLASS = 'version';
13our (@ISA, $STRICT, $LAX);
a7ad731c 14
16885730 15# avoid using Exporter
0a24517e 16require version::regex;
16885730
JP
17*version::is_lax = \&version::regex::is_lax;
18*version::is_strict = \&version::regex::is_strict;
db9cb848 19*LAX = \$version::regex::LAX;
dddb2275
JP
20*LAX_DECIMAL_VERSION = \$version::regex::LAX_DECIMAL_VERSION;
21*LAX_DOTTED_DECIMAL_VERSION = \$version::regex::LAX_DOTTED_DECIMAL_VERSION;
db9cb848 22*STRICT = \$version::regex::STRICT;
dddb2275
JP
23*STRICT_DECIMAL_VERSION = \$version::regex::STRICT_DECIMAL_VERSION;
24*STRICT_DOTTED_DECIMAL_VERSION = \$version::regex::STRICT_DOTTED_DECIMAL_VERSION;
91152fc1 25
c8a14fb6 26sub import {
c8a14fb6 27 no strict 'refs';
f941e658
JP
28 my ($class) = shift;
29
30 # Set up any derived class
4141ef59 31 unless ($class eq $CLASS) {
f941e658 32 local $^W;
4141ef59
JP
33 *{$class.'::declare'} = \&{$CLASS.'::declare'};
34 *{$class.'::qv'} = \&{$CLASS.'::qv'};
f941e658
JP
35 }
36
37 my %args;
38 if (@_) { # any remaining terms are arguments
39 map { $args{$_} = 1 } @_
40 }
41 else { # no parameters at all on use line
5027b3af 42 %args =
f941e658
JP
43 (
44 qv => 1,
45 'UNIVERSAL::VERSION' => 1,
46 );
47 }
91152fc1 48
f941e658 49 my $callpkg = caller();
5027b3af 50
f941e658 51 if (exists($args{declare})) {
5027b3af 52 *{$callpkg.'::declare'} =
f941e658
JP
53 sub {return $class->declare(shift) }
54 unless defined(&{$callpkg.'::declare'});
55 }
56
57 if (exists($args{qv})) {
61a0cb1c 58 *{$callpkg.'::qv'} =
f941e658 59 sub {return $class->qv(shift) }
61a0cb1c 60 unless defined(&{$callpkg.'::qv'});
f941e658 61 }
c0b17f21 62
4141ef59
JP
63 if (exists($args{'UNIVERSAL::VERSION'})) {
64 local $^W;
65 *UNIVERSAL::VERSION
66 = \&{$CLASS.'::_VERSION'};
67 }
68
f941e658 69 if (exists($args{'VERSION'})) {
4141ef59 70 *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'};
61a0cb1c
JP
71 }
72
73 if (exists($args{'is_strict'})) {
4141ef59 74 *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'}
d54f8cf7 75 unless defined(&{$callpkg.'::is_strict'});
61a0cb1c
JP
76 }
77
78 if (exists($args{'is_lax'})) {
4141ef59 79 *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'}
d54f8cf7 80 unless defined(&{$callpkg.'::is_lax'});
f941e658 81 }
c8a14fb6 82}
a7ad731c 83
91152fc1 84
a7ad731c 851;