Multiple choice perl

In Perl, which switch is used for printing out warnings about typographical errors in your script?

  1. -P

  2. -W

  3. -p

  4. -w

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The -w switch in Perl enables warnings, alerting you to potential issues including typos, uninitialized variables, and other problems in your script. This is a best practice for Perl development to catch errors early. The -W capital version enables ALL warnings regardless of scope.

AI explanation

To answer this question, we need to understand the different switches used in Perl for printing out warnings about typographical errors in a script.

Option A) -P - This option is incorrect because the -P switch in Perl is used for enabling parsing of files with the .P extension. It does not relate to printing out warnings about typographical errors.

Option B) -W - This option is incorrect because the -W switch in Perl is used to enable all warnings, including additional warnings not covered by the -w switch.

Option C) -p - This option is incorrect because the -p switch in Perl is used to add a loop around your script, which makes it iterate over input lines and automatically prints each line.

Option D) -w - This option is correct because the -w switch in Perl is used to enable warnings. When enabled, it prints out warnings about typographical errors in your script.

Therefore, the correct answer is D) -w. This option is correct because it is used in Perl to print out warnings about typographical errors in your script.