in reply to Is there a better way to do this?

Perhaps the simplest method would be to have your main module define stubs for those methods that you want to parcel off into other submodules.

Something like (Untested. I may have the details wrong, its not something you use every day):

sub addition { ## stub no strict 'refs'; require 'Date::Math::Add'; *addition = \&Data::Math::Add::addition; goto &addition; }

The first time the stub method is called, it dynamically requires the sub module and then fixes up the linkage by replacing its own reference with that of the method from the newly loaded module; before finally transferring control (via the special goto) to the loaded method.

Subsequent calls would go directly to the loaded method.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.