[Israel.pm] use and require

Shmuel Fomberg owner at semuel.co.il
Sat Mar 19 20:15:04 PDT 2011


On 2011/03/13 19:45, sawyer x wrote:
>
>     Whenever I see 'require' used instead of 'use', I expect problems
>     in the
>     module-dependency tree.
>
>
> I think there are benefits to both. It depends, as always, on your needs.
>
> If you have a healthy build process, you can use "require" instead of 
> "use" when you want to allow some features to be lazy, and that's very 
> useful. You can also allow loading two different versions of the same 
> mechanism, depending on some logic. If you have this, load that one, 
> if not, load this one. Imagine Mouse only uses Moose if it's already 
> loaded, saving you a ton on compile-time.
While you are right, I think that these 'require' statements should be 
in very specific places. plugins finding and loading code, dynamic 
feature loading, and so on.
but not littered through the code.
Especially the main perl file, should 'use' all the modules that are 
known to be needed for running it. no point leaving it to later point of 
time.

Shmuel.


More information about the Perl mailing list