Perl.Org wrote:
Gunnar Hjalmarsson wrote
But if you want to ensure that warnings is enabled, the
equivalent of using the -w switch is to give the $^W variable a
true value. Note that unlike "use warnings;", this enables
warnings dynamically, not lexically.

For modules, can I just put this after the package declaration, or do I have to put it in each subroutine?

$^W = 1;

I was afraid you'd ask something like that...

I take for granted that you have read about $^W in "perldoc perlvar".
I *think* it's possible to just put that after the package
declaration, but at the same time I don't think it's advisable to do
so, since it might lead to enabling warnings throughout your
application, such as other modules as well.

In a CPAN module I wrote, there is only one subroutine that is called
from other packages, and there I have

    local $^W = 1;

in the beginning of *that subroutine*.

I know that "Programming Perl" includes a section that describes this.
But it would be great if some of the experts on this list jumped in
and explained it better than I'm able to.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to