Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Created July 2, 2011 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karupanerura/1061108 to your computer and use it in GitHub Desktop.
Save karupanerura/1061108 to your computer and use it in GitHub Desktop.
Exporter::All
package Exporter::All;
use strict;
use warnings;
sub import {
my $class = shift;
my $caller = caller;
{
no strict 'refs';
my $symbol_table = \%{"${caller}::"};
my @methods =
grep { defined(*{$symbol_table->{$_}}{CODE}) }
(keys %$symbol_table);
${"${caller}::EXPORT_TAGS"}{all} = \@methods;
@{"${caller}::EXPORT_OK"} = @methods;
}
}
1;
use Example qw/:all/;
print foo(); # it is print foo
print bar(); # it is print bar
print buz(); # it is print buz
use strict;
use warnings;
use Exporter::All;
use Exporter::Lite; # or use parent 'Exporter';
sub foo { 'foo' }
sub bar { 'bar' }
sub buz { 'buz' }
1;
@karupanerura
Copy link
Author

All Lite!(all right!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment