|
Posted by Gunnar Hjalmarsson on January 9, 2008, 6:10 pm
Please log in for more thread options
Claudio Calvelli wrote:
>> You can set the $^W variable directly.
>>
>> package MyPackage;
>> use strict;
>> local $^W = 1;
>>
>> Btw, by localizing it, warnings would not be enabled outside the
>> package, right?
>
> They would not even be enabled inside the package though. The "local" will
> mean that $^W is one during the module initialization, but not when its
> code is called later.
Which wouldn't have been necessary to point out, if you hadn't snipped
my next sentence ("... only catch compile time warnings"). :(
> You could add "local $^W = 1" at the start of every sub within your package,
Those subs that are intended to be called from outside the package would do.
> but that would enable warnings in any subroutine called from it, even if it
> is in another package, which is probably bad manners.
That's a philosophical aspect on which I for one have no firm opinion. ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|