Brian McCauley wrote:
> Gunnar Hjalmarsson wrote:
>> DKW wrote:
>>> If I rephrase my question:
>>> Can you at runtime check for existence for a module, and use (or no)
>>> it if it exists?
>>
>> For an ordinary module you can do e.g.:
>>
>> BEGIN { eval "use SomeModule" }
>>
>> but the problem with "warnings" is that it's a pragma whose effect is
>> set lexically.
>
> That does not prevent the more verbose form from working:
>
> BEGIN {
> if ( eval { require warnings; 1 } ) {
> warnings->unimport('uninitialized');
> }
> }
>
> Or even just
>
> BEGIN {
> eval {
> require warnings;
> warnings->unimport('uninitialized');
> }
> }
Hmm.. So
no warnings 'uninitialized';
does only affect the current block, while
warnings->unimport('uninitialized');
is more widely applied. Is the latter file scoped or dynamically scoped?
Btw, is it documented anywhere?
Anyway: Thanks, Brian, that should be exactly what the OP is looking for.
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl