|XP is just a number|
Re: including modules during runtime and dealing with OS specific (constants) code blockby armstd (Friar)
|on Aug 02, 2011 at 17:14 UTC||Need Help??|
eval "use Win32::File";
You can just use 'require' instead if you just want it to happen at runtime.require Win32::File;
I even go as far as using 'require' more than I use 'use' these days for modules it seems. You lose the questionable benefits of import(), but you're not taking advantage of import() in this example anyway. As chromatic already pointed out, you'll want to avoid barewords referring to code that hasn't been compiled yet, addressing them as functions by appending '()' will work fine. No need for the '&'.
In my experience, dynamically compiling during runtime is great, especially when loading a large number of modules over an NFS mount. Only loading what's needed as its needed will improve response time, reducing the initial compilation time. But compilation errors in the middle of execution can be bad, and that's why you really want the 'eval'. Not just to make use work at runtime, but to make sure runtime compilation errors are caught and handled in a user-friendly way.
This is like what I do in my Abstract Factories: