Table of Contents


Consider for a moment this little program:


open OUT, ">$outfile" or die "Can't open $outfile for write:$!\n";

$delay=2 if $input[0] eq 'sleep';

sleep $delay;

print "The first element of \@input is $input[0]\n";
print OUY "Slept $delay!\n";

It doesn't do much. Just prints out the first argument supplied, and demonstrates the uninspiring sleep function. The program itself is full of holes, and it is only a few lines. How many errors can you spot? Try and count them. When you are finished, execute the program with error-checks enabled:

perl -w hello

Perl finds quite a few errors. The -w switch finds, among other heinous sins:

So, generally, -w is a Good Thing. It forces you to write cleaner code. So use it, but don't be afraid not to for very short programs.