in reply to Difference between warnings pragma or enabling warnings using -w switch?

Create two pieces of code, test1.pl and blah.pm:

use warnings; use blah; sprintf("%d\n", 1); #this is always warned, as it is in a scope with " +use warnings" declared

And here is blah.pm:

package blah; sprintf("%d\n;", 1); 1;

Run perl test1.pl, you get:

Useless use of a constant in void context at test1.pl line 5.

With perl -w test1.pl, you get:

Useless use of a constant in void context at blah.pm line 3. Useless use of a constant in void context at test1.pl line 5.

Replies are listed 'Best First'.
Re^2: Difference between warnings pragma or enabling warnings using -w switch?
by Taulmarill (Deacon) on Aug 30, 2005 at 08:46 UTC
    i'd like to add, that you could say no warnings; in blah.pm, which would turn off the warnings for the enclosing block.