Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: Re: A Guide to Installing Modules

by mirod (Canon)
on Dec 29, 2001 at 13:53 UTC ( [id://135112]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Re: A Guide to Installing Modules
in thread A Guide to Installing Modules

I found at least one good reason to do this: if the code you are writing tests whether a module is available (through an eval { require Module;} and defaults to a less-than-optimal-but-acceptable behaviour if the eval returns an error. Then you need to test both cases, with and without the module. A workaround is to wrap the eval in a test controlled by an environment variable, so when testing you can pretend that the module was not here. This is not perfect (the module could be imported by an other part of yur code or by an other module) but it is usually the easiest way to "desinstall" a module.

  • Comment on Re: Re: Re: Re: A Guide to Installing Modules

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: A Guide to Installing Modules
by Fastolfe (Vicar) on Jan 02, 2002 at 21:47 UTC
    In this situation I would simply modify my code to allow me to test both situations by only requiring the module if a certain flag was set (or unset). Then I could just flip the value of the flag whenever I wanted to test the other bit of code. Certainly easier than uninstalling/reinstalling modules.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://135112]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.