Perl command line switch, used to turn on several very helpful warnings.

Typically, your Perl program should always have this sort of beginning:

#!/usr/bin/perl -w

use strict;

or, in the days of Perl 5.6,

#!/usr/bin/perl

use warnings;
use strict;

While Perl doesn't require strictness and warnings of Bad Habits, you bloody well should enable them, lest you dwell in the land of messy memory for ever, or worst of all - the mockery from Python zealots shall ring in your ears.

Perl creators consider the fact that -w or use warnings; isn't mandatory a bug. Regrettably, it can't be enabled by default - it would break amazing amounts of old code - but it's definitely recommended for all new code.

In the program code, -w has a different meaning, similiar to Bourne shell meaning. It tests whether a file is writeable or not:

if(!-w $file) {
   die "$0: the file $file isn't writeable.\n";
}

Log in or registerto write something here or to contact authors.