On Tue, Sep 19, 2000 at 01:19:05PM -0400, John Porter wrote:
> Michael G Schwern wrote:
> > Would anyone find it useful to have a UNIVERSAL method which reports
> > on what sybols a given module exports?  
> 
> I don't see any reason why this should be anything other than a module.
> A module in the core, if it's that important.

Well, the code is tiny:

sub exports {
    my($exporter) = shift;

    my %exports = map { $_ => 1 } @{$exporter.'::EXPORT'}, 
                                  @{$exporter.'::EXPORT_OK'};

    return @_ ? exists $exports{$_[0]}
              : keys %exports;
}

and it can take advantage of the cached @EXPORT and @EXPORT_OK hash
which UNIVERSAL::import() would create.  Also, it means you wouldn't
have to type C<require UNIVERSAL::exports;>

-- 

Michael G Schwern      http://www.pobox.com/~schwern/      [EMAIL PROTECTED]
Just Another Stupid Consultant                      Perl6 Kwalitee Ashuranse
BOFH excuse #347:

The rubber band broke

Reply via email to