So what do you do when you need to load a module from a string? Do you do eval "require $module" ? Well as many of you may have read, that is How (not) to Load a Module. This mechanism is unsafe in certain situations, but sadly there hasn’t been a good answer for it.

What do you do when you want to load a module only if it is installed, or only if it is of a certain version or higher (without die ing). Of course there are eval ways around that too, but could they be easier?

This post announces Module::UseFrom , which lets you do all of these things. But it gets better! All of these actions are done using the much safer bareword form of use , accomplishes this at compile time, and does it without any eval s[1]!

It does all this using Devel::Declare to inspect a package variable in your module and inject a bareword use statement. This means that it avoid most (all?) of the problems Schwern’s post (above); if it fails to create the right statement, perl (yes lowercase) dies on the use Bareword::Module statement.

Check it out, fork, comment etc. https://github.com/jberger/Module-UseFrom

Happy New Year everyone!