1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#
# (c) Jan Gehring <jan.gehring@gmail.com>
#
package Rex::Exporter;
use v5.12.5;
use warnings;
use Symbol;
our $VERSION = '1.14.1'; # VERSION
use Data::Dumper;
our @EXPORT;
sub import {
my ( $mod_to_register, %option ) = @_;
my ( $mod_to_register_in, $file, $line ) = caller;
if ( exists $option{register_in} && $option{register_in} ) {
$mod_to_register_in = $option{register_in};
}
my $no_import = "";
if ( exists $option{"-no"} && $option{"-no"} ) {
$no_import = "," . join( ",", @{ $option{"-no"} } ) . ",";
}
my $ref_to_export = qualify_to_ref( 'EXPORT', $mod_to_register );
my $ref_to_export_array = *{$ref_to_export}{ARRAY};
for my $reg_func ( @{$ref_to_export_array} ) {
if ( $no_import =~ m/,$reg_func,/ ) {
next;
}
my $ref_to_reg_func_in_source_mod =
qualify_to_ref( $reg_func, $mod_to_register );
my $ref_to_reg_func_in_target_mod =
qualify_to_ref( $reg_func, $mod_to_register_in );
*{$ref_to_reg_func_in_target_mod} = *{$ref_to_reg_func_in_source_mod};
}
}
1;
|