This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Log::Message::Simple from ext/ to cpan/
[perl5.git] / lib / version.pm
1 #!perl -w
2 package version;
3
4 use 5.005_04;
5 use strict;
6
7 use vars qw(@ISA $VERSION $CLASS *declare *qv);
8
9 $VERSION = 0.77;
10
11 $CLASS = 'version';
12
13 # Preloaded methods go here.
14 sub import {
15     no strict 'refs';
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     }
36     
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     }
50
51     if (exists($args{'VERSION'})) {
52         *{$callpkg."::VERSION"} = \&version::_VERSION;
53     }
54 }
55
56 1;