Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: using 'use' conditionally

by BUU (Prior)
on Nov 06, 2002 at 02:09 UTC ( [id://210629]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://210629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-20 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found