Some hints applied, so the examples using a string are broken. :) Thank you all to finding this out. :)1 package Package::Subroutine 2 ; our $VERSION = '0.06' 3 4 ; sub export 5 { my $ns = (caller(1))[0] 6 ; shift() # rm package 7 # working shortcut for __PACKAGE__ 8 ; splice(@_,0,1,"".caller) if $_[0] eq '_' 9 ; _import_export($ns,@_) 10 } 11 12 ; sub import 13 { my $ns = (caller(0))[0] 14 ; shift() # rm package 15 ; _import_export($ns,@_) 16 } 17 18 ; sub _import_export 19 { my $namespace = shift 20 ; my $from = shift 21 ; my @methods = @_ 22 23 ; for ( @methods ) 24 { my $target = "${namespace}::${_}" 25 ; my $source = "${from}::${_}" 26 ; *$target = \&$source 27 } 28 } 29 30 ; sub version 31 { my ($f,$pkg,$num)=@_ 32 ; if( defined($num) ) 33 { $num=eval { UNIVERSAL::VERSION($pkg,$num) } 34 ; return $@ ? undef : $num 35 } 36 ; eval { UNIVERSAL::VERSION($pkg) } 37 } 38 39 ; sub install 40 { my ($pkg,$target,$name,$coderef)=@_ 41 ; $target="${target}::${name}" 42 ; *$target = $coderef 43 } 44 45 ; 1 46 47 __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: to much hybries
by ysth (Canon) on Feb 08, 2007 at 00:18 UTC | |
by pmSwim (Acolyte) on Feb 08, 2007 at 19:27 UTC | |
by ysth (Canon) on Feb 08, 2007 at 19:56 UTC | |
by Anonymous Monk on Feb 08, 2007 at 21:24 UTC | |
|
Re: to much hybries
by eric256 (Parson) on Feb 07, 2007 at 23:53 UTC | |
by pmSwim (Acolyte) on Feb 08, 2007 at 18:54 UTC | |
by ysth (Canon) on Feb 09, 2007 at 00:38 UTC | |
by pmSwim (Acolyte) on Feb 09, 2007 at 19:30 UTC | |
|
Re: to much hubris
by dragonchild (Archbishop) on Feb 09, 2007 at 01:30 UTC |