Skip Menu |

This queue is for tickets about the Module-Load-Conditional CPAN distribution.

Report information
The Basics
Id: 44488
Status: resolved
Worked: 1 min
Priority: 0/
Queue: Module-Load-Conditional

People
Owner: BINGOS [...] cpan.org
Requestors: alaric [...] caerllewys.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Usage question using Module::Load::Conditional
Date: Sun, 22 Mar 2009 17:38:53 -0400
To: bug-module-load-conditional [...] rt.cpan.org
From: Brother Railgun of Reason <alaric [...] caerllewys.net>
Hi, I just looked at Module::Load::Conditional for a method of enabling encryption in a program if all required modules are available, or disabling it and continuing if they're not. I ran into just one problem. The modules I need to load for encryption are as follows: use Crypt::CBC; use Crypt::Blowfish; use Digest::SHA1 qw(sha1_base64); use MIME::Base64; use Compress::Zlib; use Math::BigInt try => 'GMP'; use Crypt::DH; Most of these are no problem. But there is no documented support for the qw or try syntax as used for Digest::SHA1 and Math::BigInt. I'm assuming I could work around the try problem by trying to load Math::BigInt::GMP, then Math::BigInt if it fails. But I see no way to work around thw qw() usage, without which Digest::SHA1 exports no functions by default. Is there an undocumented means of supporting these usages with Module::Load::Conditional? If not, can you suggest a workaround? Thanks. -- Phil Stracchino, CDK#2 DoD#299792458 ICBM: 43.5607, -71.355 alaric@caerllewys.net alaric@metrocast.net phil@co.ordinate.org Renaissance Man, Unix ronin, Perl hacker, Free Stater It's not the years, it's the mileage.
On Mon Mar 23 17:14:44 2009, alaric@caerllewys.net wrote: Show quoted text
> Hi, > I just looked at Module::Load::Conditional for a method of enabling > encryption in a program if all required modules are available, or > disabling it and continuing if they're not. I ran into just one > problem. > > The modules I need to load for encryption are as follows: > > use Crypt::CBC; > use Crypt::Blowfish; > use Digest::SHA1 qw(sha1_base64); > use MIME::Base64; > use Compress::Zlib; > use Math::BigInt try => 'GMP'; > use Crypt::DH; > > Most of these are no problem. But there is no documented support for > the qw or try syntax as used for Digest::SHA1 and Math::BigInt. > > I'm assuming I could work around the try problem by trying to load > Math::BigInt::GMP, then Math::BigInt if it fails. But I see no way to > work around thw qw() usage, without which Digest::SHA1 exports no > functions by default. > > Is there an undocumented means of supporting these usages with > Module::Load::Conditional? If not, can you suggest a workaround?
There's currently no (un)documented way to do this. It might be a worthwile extension, but in the meantime, you can do this: if( can_load( modules => { foo => 1 } } ) { foo->import( qw[func1 func2] ); ... # your code here } Hope this helps,
Subject: Re: [rt.cpan.org #44488] Usage question using Module::Load::Conditional
Date: Fri, 24 Apr 2009 16:51:26 -0400
To: Jos Boumans via RT <bug-Module-Load-Conditional [...] rt.cpan.org>
From: Phil Stracchino <alaric [...] caerllewys.net>
On Fri, Apr 24, 2009 at 10:24:43AM -0400, Jos Boumans via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=44488 > > On Mon Mar 23 17:14:44 2009, alaric@caerllewys.net wrote:
> > I'm assuming I could work around the try problem by trying to load > > Math::BigInt::GMP, then Math::BigInt if it fails. But I see no way to > > work around thw qw() usage, without which Digest::SHA1 exports no > > functions by default. > > > > Is there an undocumented means of supporting these usages with > > Module::Load::Conditional? If not, can you suggest a workaround?
> > There's currently no (un)documented way to do this. It might be a > worthwile extension, but in the meantime, you can do this: > > > if( can_load( modules => { foo => 1 } } ) { > foo->import( qw[func1 func2] ); > > ... # your code here > } > > Hope this helps,
Thanks for the tip. I actually already worked around it another way, but this is probably cleaner. -- Phil Stracchino, CDK#2 DoD#299792458 ICBM: 43.5607, -71.355 alaric@caerllewys.net alaric@metrocast.net phil@co.ordinate.org Renaissance Man, Unix ronin, Perl hacker, Free Stater It's not the years, it's the mileage.
Closing ticket.