develooper Front page | perl.perl5.porters | Postings from April 2001

Re: [PATCH] UNIVERSAL shouldn't require Exporter

Thread Previous | Thread Next
From:
Abhijit Menon-Sen
Date:
April 26, 2001 03:53
Subject:
Re: [PATCH] UNIVERSAL shouldn't require Exporter
Message ID:
20010426162234.C26921@lustre.linux.in
On 2001-04-26 04:54:17, barries@slaysys.com wrote:
>
> > There should not be an import{} method at all.
> 
> Cat's out of the bag on this on, I think.  Quoth perlobj: [...]
> 
> 	 use UNIVERSAL qw(isa);

How about this, then?

- ams

--- perl@9818/lib/UNIVERSAL.pm~	Thu Apr 26 03:14:28 2001
+++ perl@9818/lib/UNIVERSAL.pm	Thu Apr 26 16:21:24 2001
@@ -2,12 +2,17 @@
 
 our $VERSION = '1.00';
 
-# UNIVERSAL should not contain any extra subs/methods beyond those
-# that it exists to define. The use of Exporter below is a historical
-# accident that should be fixed sometime.
-require Exporter;
-*import = \&Exporter::import;
-@EXPORT_OK = qw(isa can);
+sub import
+{
+    no strict 'refs';
+    my $pkg = caller;
+
+    foreach my $sym (@_) {
+        if ($sym eq "isa" || $sym eq "can") {
+            *{"${pkg}::$sym"} = \&$sym;
+        }
+    }
+}
 
 1;
 __END__

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About