Perl: Is there a difference between usage warnings and -w?

I have the habit of running any perl script using shebang / use strict / use warnings right off the bat. I notice that other people around my work use "-w" on the shebang line instead. Is there any real difference? I conducted several tests, intentionally causing warnings, and both methods had the same results, but are more effective or better than others than others?

#!/usr/bin/perl -w 

vs

 #!/usr/bin/perl use warnings; 
+4
source share
1 answer

-w precedes lexical warnings allowed by the warning pragma; I suspect that they simply did not move with time.

use warnings gives you much more control over which warnings will be triggered, and also allows you to promote some warnings as fatal errors. It also applies only to the lexical area in which you are located, while -w will apply even to loadable modules that do not expect warnings (which, fortunately, are small and far apart).

+12
source

All Articles