This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Performance optimisation in assert, suggested by Tim Bunce
[perl5.git] / lib / version.pm
CommitLineData
c8d69e4a 1#!perl -w
a7ad731c
HS
2package version;
3
c8a14fb6 4use 5.005_04;
a7ad731c
HS
5use strict;
6
f941e658 7use vars qw(@ISA $VERSION $CLASS *declare *qv);
a7ad731c 8
f941e658 9$VERSION = 0.77;
a7ad731c
HS
10
11$CLASS = 'version';
12
a7ad731c 13# Preloaded methods go here.
c8a14fb6 14sub import {
c8a14fb6 15 no strict 'refs';
f941e658
JP
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
JP
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
JP
51 if (exists($args{'VERSION'})) {
52 *{$callpkg."::VERSION"} = \&version::_VERSION;
53 }
c8a14fb6 54}
a7ad731c
HS
55
561;