in reply to dynamic symbol Exporter
Your code is just defining the subroutines within the A namespace. You could use caller to return the namespace in which you want the subroutine exported.
sub build_funcs { my $package = caller; foreach ('A', 'B', 'C') { eval " print \"building $_ func\\n\"; sub $package\::${_}_func { print \"$_ func called\\n\"; } "; push @EXPORT, "${_}func"; } }
Of course, you could also use AutoLoader in combination with @ISA in your test script to have an AUTOLOAD that creates the subroutine for you. Also, on a side note, don't get in the habit of calling subroutines as &sub unless you know why you're doing it. Instead use sub(). Read perldoc perlsub for more information about it. I hope this helps you with your problem.
|
|---|