This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Changed Copyright year as suggested by karl williamson in http://nntp.perl.org/group...
[perl5.git] / lib / version.pm
index 56efdaf..9201a02 100644 (file)
@@ -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.48";
+$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;