Re: How to 'conditionally' use a specified module



"u" == usenet <usenet@xxxxxxxxxxxxxxx> writes:

u> danny wrote:
>> I need to check if one of my variables is true, then use a specific module:

u> Use the 'if' pragma (which is different than the "usual" if operator):

u> use if ($use_cache eq 'yes'), Cache::SizeAwareFileCache;

that will still fail if the boolean value is set at runtime since use
executes at compile time. this is where require is better as it only
executes at runtime. (of course string eval breaks all those rules).

so to the OP, you need to call require and not use there.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.



Relevant Pages

  • Re: How to conditionally use a specified module
    ... that will still fail if the boolean value is set at runtime since use ... executes at compile time. ...
    (perl.beginners)
  • Re: How to conditionally use a specified module
    ... u> danny wrote: ... that will still fail if the boolean value is set at runtime since use ... executes at compile time. ... I hadn't heard of the if pragma before David mentioned it, ...
    (perl.beginners)
  • Re: How to conditionally use a specified module
    ... that will still fail if the boolean value is set at runtime since use ... executes at compile time. ... The if pragma executes at compile time. ...
    (perl.beginners)
  • VB6 SP6 BUG Using NOT keyword??!!!
    ... I have a function (which returns a Boolean) call that checks for an existing Internet connection, and executes a block of code if the connection does not exist, as such: ... Whenever the CheckInternet function returns TRUE, the condition executes anyway. ... Dim bResult As Boolean ...
    (microsoft.public.vb.bugs)
  • Re: OT: Linux Interview Questions
    ... executes them sequentially as long as none of them fail, ... return a 1 and the whole statement will fail. ... I find bash scripting very cryptic and I don't mean that as ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)