I read in Simon Cozens' book "Beginning Perl" that -w switch for warnings would be dep开发者_开发技巧recated going forward. Is this true or is it still ok to continue using -w rather than "use warnings".
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.
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.)
精彩评论