in reply to Re: Using a 'package' as a 'module', and choosing at runtime?
in thread Using a 'package' as a 'module', and choosing at runtime?

require is definitely a good and straight answer to the question, and I believe this must be one of the original reasons made them to have require in Perl in the first place. As sometime, you simply either cannot determine what to use at compile time, or you cannot determine whether you even require anything.

The other way seems also very natual is to have a base class and those platform-specific classes subclass it. Less efficient, but chance is that there are common attributes across platforms, and could be a pretty neat design.

Actually should be a mixture of both, a neat OO design with dynamically loading of subclasses.

  • Comment on Re: Re: Using a 'package' as a 'module', and choosing at runtime?