I am interested in the difference between the use warnings pragma and the -w switch. Iv looked and I cant find anyone actually giving any reason for there choice in using either version. However seeing as in my first post to this forum I was told -
The -w flag on the shebang line turns on warnings. But you should not use it and use the warnings pragma instead:
use warnings;
I am interested to know if there is actually a reason behind this, or if it is just a matter of personal preference/coding style.
They seem to me to be doing the same thing. They both turn on warnings.
The use warnings pragma can be turned off within blocks of code by using -
sub foo {
no warnings;
...
}
However it seems that as the -w switch sets the value $^W = 1, that you could use -
sub foo {
my $^W = 0;
...
}
to disable warnings within a subroutine. Ok, so my $^W=0 is not as readable as no warnings...surely this cant be the only point against -w?
As -w is a quicker to type and they appear to do the same thing, is there any reason for 1 version over the other?