Re: How to 'conditionally' use a specified module
- From: "danny" <dannymiles2@xxxxxxxxx>
- Date: 16 Nov 2006 09:16:15 -0800
Uri Guttman wrote:
"u" == usenet <usenet@xxxxxxxxxxxxxxx> writes:
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.
Hi Uri,
Thanks for the advise. Unfortunately I can't use require because the
code I fixed is inside a module and I can only reference with
MyPackage::This and MyPackage::That.
In my particular situation, David Filmer's tip worked perfectly.
my $use_cache = 'no';
use if ($use_cache eq 'yes'), 'Cache::SizeAwareFileCache';
That fixed everything.
But I'll remember your advise in case next time I needed to use
something like this and couldn't get it to work with if pragma.
--Danny
.
- Follow-Ups:
- Re: How to 'conditionally' use a specified module
- From: Uri Guttman
- Re: How to 'conditionally' use a specified module
- From: Paul Lalli
- Re: How to 'conditionally' use a specified module
- References:
- How to 'conditionally' use a specified module
- From: danny
- Re: How to 'conditionally' use a specified module
- From: usenet
- Re: How to 'conditionally' use a specified module
- From: Uri Guttman
- How to 'conditionally' use a specified module
- Prev by Date: Re: subroutine call makes foreach exit?
- Next by Date: Adding files matching pattern to an array
- Previous by thread: Re: How to 'conditionally' use a specified module
- Next by thread: Re: How to 'conditionally' use a specified module
- Index(es):
Relevant Pages
|