How to 'conditionally' use a specified module



Hello everyone,

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

my $use_cache = 'no';

if ($use_cache == 'yes'){
use Cache::SizeAwareFileCache;
}

The problem I have is that no matter if $use_cache is yes or no, Perl
always try to evaluate the use of Cache::SizeAwareFileCache at run-time
and if I don't have that module installed, it gives me an error:
Couldn't find the module "Cache/SizeAwareFileCache.pm".

Even though I stated clearly that $use_cache = 'no', Perl still reports
that Cache::SizeAwareFileCache is not installed.

What exactly am I missing here? Is there an easy way to ignore the
missing module inside a condition?

Thanks

--Danny

.



Relevant Pages

  • Re: Adding a delimiter inbetween number characters and letter characters
    ... necessary minimum) quotes of the relevant material you're replying ... COMPLEX regexen tend to become confusing, ... IF RTM is a matter of a few lines that first or later you ... Perl, that is... ...
    (comp.lang.perl.misc)
  • Re: Creating reports ??
    ... I want to know what people think or have used to create reports in perl. ... Maybe creating some kind of graph or an excell report? ... For graphs, I've always used jpgraph. ...
    (perl.beginners)
  • RE: monitoring corporate internet usage
    ... If there is an issue posting perl code then I ... > have it log to a linux server and generate reports like those mentioned ... I currently have my PIX racked and plugged in, ... > Subject: RE: monitoring corporate internet usage ...
    (Security-Basics)
  • Re: strange, please explain
    ... Do NOT use 'chop'. ... It probably doesn't matter with this particular file that you happen ... Every Perl text book explains that. ... Your code writing style is quite clean if you are a beginner. ...
    (perl.beginners)
  • Re: perl OOP
    ... It's not a matter of belief. ... How is someone less familiar with Perl to ... What benefit do you see in misleading him with incorrect ... Web Hosting by West Virginians, ...
    (comp.lang.perl.misc)