eval "package $caller;"; Foo::Core->import(@imports);
I suppose this doesn't work because the package needs to be known at compile time...
Try this
eval "package $caller; Foo::Core->import(\@imports)";
Update: something like this works for me:
package Foo::Core; use Exporter qw(import); our @EXPORT_OK = qw(func_a); sub func_a { print "in func_a(): @_\n"; } 1; ----- package Foo::Core::Specialized; use Foo::Core; sub import { my $this_pkg = shift; my @imports = @_; foreach (my $i = 0; $i < scalar(@imports); $i++) { if ($imports[$i] eq 'Mixed') { print "doing something with 'Mixed'...\n"; splice(@imports, $i--, 1); } } my $caller = caller(); eval "package $caller; Foo::Core->import(\@imports)"; } 1; ----- #!/usr/bin/perl use Foo::Core::Specialized qw(Mixed func_a); func_a(42, 'foo'); __END__ $ ./807805.pl doing something with 'Mixed'... in func_a(): 42 foo
In reply to Re: Creating "parasitic" exports
by almut
in thread Creating "parasitic" exports
by sirrobert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |