Commit | Line | Data |
---|---|---|
c8d69e4a | 1 | #!perl -w |
a7ad731c | 2 | package version; |
3 | ||
c8a14fb6 | 4 | use 5.005_04; |
a7ad731c | 5 | use strict; |
6 | ||
f941e658 | 7 | use vars qw(@ISA $VERSION $CLASS *declare *qv); |
a7ad731c | 8 | |
f941e658 | 9 | $VERSION = 0.77; |
a7ad731c | 10 | |
11 | $CLASS = 'version'; | |
12 | ||
a7ad731c | 13 | # Preloaded methods go here. |
c8a14fb6 | 14 | sub import { |
c8a14fb6 | 15 | no strict 'refs'; |
f941e658 | 16 | my ($class) = shift; |
17 | ||
18 | # Set up any derived class | |
19 | unless ($class eq 'version') { | |
20 | local $^W; | |
21 | *{$class.'::declare'} = \&version::declare; | |
22 | *{$class.'::qv'} = \&version::qv; | |
23 | } | |
24 | ||
25 | my %args; | |
26 | if (@_) { # any remaining terms are arguments | |
27 | map { $args{$_} = 1 } @_ | |
28 | } | |
29 | else { # no parameters at all on use line | |
30 | %args = | |
31 | ( | |
32 | qv => 1, | |
33 | 'UNIVERSAL::VERSION' => 1, | |
34 | ); | |
35 | } | |
c8a14fb6 | 36 | |
f941e658 | 37 | my $callpkg = caller(); |
38 | ||
39 | if (exists($args{declare})) { | |
40 | *{$callpkg."::declare"} = | |
41 | sub {return $class->declare(shift) } | |
42 | unless defined(&{$callpkg.'::declare'}); | |
43 | } | |
44 | ||
45 | if (exists($args{qv})) { | |
46 | *{$callpkg."::qv"} = | |
47 | sub {return $class->qv(shift) } | |
48 | unless defined(&{"$callpkg\::qv"}); | |
49 | } | |
c0b17f21 | 50 | |
f941e658 | 51 | if (exists($args{'VERSION'})) { |
52 | *{$callpkg."::VERSION"} = \&version::_VERSION; | |
53 | } | |
c8a14fb6 | 54 | } |
a7ad731c | 55 | |
56 | 1; |