Created
May 18, 2009 06:54
-
-
Save yappo/113354 to your computer and use it in GitHub Desktop.
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
| # code base is the.pm # ingy++ | |
| use utf8; package うんこな; | |
| sub import { | |
| my $package = caller; | |
| *{"${package}::$_"} = sub { return wantarray ? @_ : $_[0] } | |
| for qw(a an teh the more); | |
| my ($class, $module) = @_; | |
| if ($module) { | |
| eval "require $module"; | |
| die $@ if $@; | |
| splice @_, 0, 1; | |
| my $import = $module->can('import') | |
| or return; | |
| goto &$import; | |
| } | |
| } | |
| sub unimport { | |
| my $package = caller; | |
| *{"${package}::$_"} = sub { return wantarray ? @_ : $_[0] } | |
| for qw(a an teh the more); | |
| my ($class, $module) = @_; | |
| if ($module) { | |
| eval "require $module"; | |
| die $@ if $@; | |
| splice @_, 0, 1; | |
| my $unimport = $module->can('unimport') | |
| or return; | |
| goto &$unimport; | |
| } | |
| } | |
| 1; | |
| __END__ | |
| example: | |
| use utf8; | |
| use うんこな Acme::Oppai; | |
| print Acme::Oppai->Oppai->Oppai->Oppai; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment