Created
July 2, 2011 16:30
-
-
Save karupanerura/1061108 to your computer and use it in GitHub Desktop.
Exporter::All
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Example qw/:all/; | |
| print foo(); # it is print foo | |
| print bar(); # it is print bar | |
| print buz(); # it is print buz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use Exporter::All; | |
| use Exporter::Lite; # or use parent 'Exporter'; | |
| sub foo { 'foo' } | |
| sub bar { 'bar' } | |
| sub buz { 'buz' } | |
| 1; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All Lite!(all right!)