wanna_code_perl has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I've built an application which is designed to run both normally on Linux, or packaged up on Win32 with Cava Packer. Cava Packer comes with Cava::Pack, which I need to fake out, because as far as I can tell, there is no equivalent module for Linux.
I've worked around this with the following code:
BEGIN { package Cava::Pack; sub Resource { $Cava::Pack::dir.'/'.$_[0]; } sub SetResourcePath { $Cava::Pack::dir = $_[0]; } sub GetInfoProductVersion { "0.9.9.0"; } }
This works fine in Linux, but in Windows I need to use the real Cava::Pack, and if I add a use Cava::Pack; line, I get function redefinition warnings (not to mention compilation fails on Linux because there is no Cava/Pack.pm in my @INC.
What I need to do is conditionally use the real Cava::Pack if it is available, or run my above code if it is not available. How do I go about that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conditionally faking a module
by Anonymous Monk on Jan 13, 2010 at 18:38 UTC | |
by wanna_code_perl (Friar) on Jan 13, 2010 at 19:03 UTC | |
|
Re: Conditionally faking a module
by bobf (Monsignor) on Jan 13, 2010 at 18:40 UTC | |
by wanna_code_perl (Friar) on Jan 13, 2010 at 19:01 UTC | |
by bobf (Monsignor) on Jan 13, 2010 at 19:14 UTC | |
by Anonymous Monk on Jan 13, 2010 at 21:27 UTC | |
by ikegami (Patriarch) on Jan 15, 2010 at 18:01 UTC | |
|
Re: Conditionally faking a module
by NiJo (Friar) on Jan 13, 2010 at 18:59 UTC | |
by Anonymous Monk on Jan 15, 2010 at 09:16 UTC | |
by NiJo (Friar) on Jan 15, 2010 at 17:29 UTC |