Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other?
example 1:
#!/usr/bin/perl use warnings;
example 2:
#!/usr/bin/perl -w
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using the switch will enable all warnings in all modules used by your program. Using the pragma you enable it only in that specific module (or script). Ideally, you use warnings in all your modules, but often that’s not the case. Using the switch can get you a lot of warnings when you use a third party module that isn’t warnings-safe.
So, ideally it doesn’t matter, but pragmatically it’s often preferable for your end-users not to use the switch but the pragma.