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