This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate CPAN release of version.pm 0.9905
[perl5.git] / cpan / version / lib / version.pm
... / ...
CommitLineData
1#!perl -w
2package version;
3
4use 5.005_05;
5use strict;
6
7use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
8
9$VERSION = 0.9905;
10$CLASS = 'version';
11
12# avoid using Exporter
13use version::regex;
14*version::is_lax = \&version::regex::is_lax;
15*version::is_strict = \&version::regex::is_strict;
16
17sub import {
18 no strict 'refs';
19 my ($class) = shift;
20
21 # Set up any derived class
22 unless ($class eq $CLASS) {
23 local $^W;
24 *{$class.'::declare'} = \&{$CLASS.'::declare'};
25 *{$class.'::qv'} = \&{$CLASS.'::qv'};
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
33 %args =
34 (
35 qv => 1,
36 'UNIVERSAL::VERSION' => 1,
37 );
38 }
39
40 my $callpkg = caller();
41
42 if (exists($args{declare})) {
43 *{$callpkg.'::declare'} =
44 sub {return $class->declare(shift) }
45 unless defined(&{$callpkg.'::declare'});
46 }
47
48 if (exists($args{qv})) {
49 *{$callpkg.'::qv'} =
50 sub {return $class->qv(shift) }
51 unless defined(&{$callpkg.'::qv'});
52 }
53
54 if (exists($args{'UNIVERSAL::VERSION'})) {
55 local $^W;
56 *UNIVERSAL::VERSION
57 = \&{$CLASS.'::_VERSION'};
58 }
59
60 if (exists($args{'VERSION'})) {
61 *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'};
62 }
63
64 if (exists($args{'is_strict'})) {
65 *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'}
66 unless defined(&{$callpkg.'::is_strict'});
67 }
68
69 if (exists($args{'is_lax'})) {
70 *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'}
71 unless defined(&{$callpkg.'::is_lax'});
72 }
73}
74
75
761;