in reply to Creating packages on the fly

You may be able to adapt some of the code from Class::CanBeA. For it to figure out what can be what, it first has to examine all the packages that have been loaded.