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".
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With