in reply to Re: using 'use' conditionally
in thread using 'use' conditionally

If you care that much about importing from the module:
if($opt_g) { require Tk; Tk->import; }
Difference goes away! wow.

Replies are listed 'Best First'.
Re: Re: Re: using 'use' conditionally
by belden (Friar) on Nov 06, 2002 at 22:46 UTC
    Difference goes away! wow.

    BUU is right. Additionally, blssu, you don't need to import if you're going to use the OO interface of whichever module you required... because good OO interfaces don't export their methods.

    blyman
    setenv EXINIT 'set noai ts=2'

Re: Re: Re: using 'use' conditionally
by blssu (Pilgrim) on Nov 07, 2002 at 16:56 UTC

    Sure, that's pretty close to what 'use' does now, but the 'eval' helps future-proof your code. The hand-rolled import isn't clever, it's just extra work. Laziness is one of the three pillars...

    The common efficiency and security disadvantages of 'eval' aren't issues here because (1) run-time 'require' must do an 'eval' eventually anyway, and (2) the 'eval' uses a string constant that is easy to understand and verify.