in reply to Sub Definitions Within Subs: Best Way to Exploit
Being able to define subroutines within subroutines is intentional. The main uses for this sort of thing is within AUTOLOAD methods, which allows subroutines to be generated "on demand". Usually a little bit of eval magic occurs here as well, to make sure an appropriately named sub is generated.
As pointed out above, a subroutine attaches itself to its current package, regardless of where you define it. This is exactly what you want for AUTOLOAD methods.
The perlbot man page has an example of using AUTOLOAD down the bottom. You might want to check it out if you're curious.
Cheers,
Paul
|
|---|