in reply to Sub on the fly?
Sure, see Sub::Installer.
Personally I prefer Sub::Install since it does not futz with UNIVERSAL to get the job done.