|Don't ask to ask, just ask|
Defining a subroutine in another packageby jmay (Sexton)
|on Jan 26, 2002 at 12:01 UTC||Need Help??|
jmay has asked for the
wisdom of the Perl Monks concerning the following question:
perldoc perlmod sez:
Subroutine definitions (and declarations, for that matter) need not necessarily be situated in the package whose symbol table they occupy. You can define a subroutine outside its package by explicitly qualifying the name of the subroutine:
This is just a shorthand for a typeglob assignment at compile time:
OK, my question: Is there a clean way to add a subroutine to another package, where the "other" package name is not known at compile time?
The best I can do is:
but I'd rather not use eval if I don't have to.