in reply to Re: Create a package that exports other packages
in thread Create a package that exports other packages
# X.pm package X; sub new { bless{ Name=> "I am X"}, shift} 1; #Y.pm package Y; require Exporter; our @ISA =qw/Exporter/; our @EXPORT_OK = qw/TestY/; sub new {bless{ Name=> "I am Y"}, shift;} sub TestY {print "@_ EXPORT_OK"} 1; #MyStuffs.pm package MyStuffs; use Import::Into; sub import { my $target = caller; X->import::into($target); Y->import::into($target, qw/TestY/); } 1; #main.pl use MyStuffs; use Data::Dumper; my $x = new X; my $y = new Y; print "X dumps: "; print Dumper $x; print "$/$/Y dumps: "; print Dumper $y; print "$/$/"; TestY("I am"); print "$/"; Y::TestY ( "Still" ) ; __END__ X dumps: $VAR1 = bless( { 'Name' => 'I am X' }, 'X' ); Y dumps: $VAR1 = bless( { 'Name' => 'I am Y' }, 'Y' ); I am EXPORT_OK Still EXPORT_OK
|
|---|