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