Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Perl's -w switch for warnings deprecated after 5.6.x?

Tags:

perl

I read in Simon Cozens' book "Beginning Perl" that -w switch for warnings would be deprecated going forward. Is this true or is it still ok to continue using -w rather than "use warnings".

like image 568
Wilderness Avatar asked Oct 19 '10 05:10

Wilderness


2 Answers

The perlrun documentation (see perldoc perlrun or this page) indicates that the -w option is still available as of Perl 5.12.2. Using the pragma gets you nifty benefits though, like turning warnings on lexically and finer grained warnings.

Here is a blurb on why you should use the pragma instead of the command line option.

like image 103
mfollett Avatar answered Nov 28 '22 07:11

mfollett


The -w option will NOT go away!

The preferred method of turning on warnings is use warnings because -w has a global effect. (In fact, -w is implemented by means of a global variable $^W. That alone should tell you that the lexical version is safer.)

like image 37
tsee Avatar answered Nov 28 '22 07:11

tsee