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

Re: [PATCH] UNIVERSAL shouldn't require Exporter

Thread Previous | Thread Next
From:
Graham Barr
Date:
April 26, 2001 05:31
Subject:
Re: [PATCH] UNIVERSAL shouldn't require Exporter
Message ID:
20010426133035.K64737@pobox.com
What is it that you think this is gaining ?

Graham.

On Thu, Apr 26, 2001 at 04:22:34PM +0530, Abhijit Menon-Sen wrote:
> 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