X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/43eaf59d25f22137101201b9df220432655a6cc2..32709fdf41543f067562e0dc9944448dd11d2c28:/lib/version.pm diff --git a/lib/version.pm b/lib/version.pm index 9443a6a..9201a02 100644 --- a/lib/version.pm +++ b/lib/version.pm @@ -1,20 +1,56 @@ #!perl -w package version; -use 5.005_03; +use 5.005_04; use strict; -require Exporter; -use vars qw(@ISA $VERSION $CLASS @EXPORT); +use vars qw(@ISA $VERSION $CLASS *declare *qv); -@ISA = qw(Exporter); - -@EXPORT = qw(qv); - -$VERSION = 0.50; +$VERSION = 0.77; $CLASS = 'version'; # Preloaded methods go here. +sub import { + no strict 'refs'; + my ($class) = shift; + + # Set up any derived class + unless ($class eq 'version') { + local $^W; + *{$class.'::declare'} = \&version::declare; + *{$class.'::qv'} = \&version::qv; + } + + my %args; + if (@_) { # any remaining terms are arguments + map { $args{$_} = 1 } @_ + } + else { # no parameters at all on use line + %args = + ( + qv => 1, + 'UNIVERSAL::VERSION' => 1, + ); + } + + my $callpkg = caller(); + + if (exists($args{declare})) { + *{$callpkg."::declare"} = + sub {return $class->declare(shift) } + unless defined(&{$callpkg.'::declare'}); + } + + if (exists($args{qv})) { + *{$callpkg."::qv"} = + sub {return $class->qv(shift) } + unless defined(&{"$callpkg\::qv"}); + } + + if (exists($args{'VERSION'})) { + *{$callpkg."::VERSION"} = \&version::_VERSION; + } +} 1;