in reply to OO factory behind simple methods

Primary concern: is the use of $class combined with the quoted eval the best approach?

No :) use existing wheel

Use Module::Load or Module::Pluggable

Replies are listed 'Best First'.
Re^2: OO factory behind simple methods
by Apero (Scribe) on Dec 18, 2015 at 03:21 UTC

    Interesting, thanks for the references; I was familiar with neither, and they both look to aid in such design. Module::Load may well do what I need; Module::Pluggable seems more flexible, although a bit overkill for this project, but it may serve well in future endeavors.

    Thanks for the information; I've included some additional findings I've made from playing with this module, and follow-up comments. I'm content that both solutions appear to work, and in my case equally well without significant benefit either way. Update: As pointed out by the Anonymous Monk below, string eval is still processed as a mini-program, leading to additional protections supplied by a more full-featured wrapper. Thanks!

    (Update: readmore tags.) My detailed discovery thus far:

      ... However, I had to do no such changing of notation when ...

      you can't use require $modname without string eval because require expects a $filename

      since string-eval takes perl source code, $type would should be validated to prevent problems

      eval "require $modname; 1" is slower than require $filename;

      so module::load helps you use require $modname by converting $modname into filename