Another approach is to use the :: MOP load_class class method. You can use it like:
Class :: MOP :: load_class ('foobar', $ some_options)
It throws an exception, so you have to catch it. More details here .
In addition, although this is not necessary for every system, the :: MOP class is extremely useful, and with Moose it is becoming more common every day, probably on your system.
source
share