in reply to The -w switch on a web application

I could be on the wrong track here, however are you defining variables before you use them? The line:
print "The string is $foo\n";
may give you an "uninitialised value, as $foo may not be defined yet. whereas:
my $foo; # some code print "The string is $foo\n";
should be better - as $foo has been defined.. Referencing into hashes, only to discover that the particular key you're trying to use does not exists is another area that results in a very similar problem :)

-- Ian Stuart
A man depriving some poor village, somewhere, of a first-class idiot.

Replies are listed 'Best First'.
Re: Re: The -w switch on a web application
by davorg (Chancellor) on Jan 31, 2003 at 12:13 UTC

    I think you're slightly confused about what these error messages mean. If you don't declare a variable, you'll get the "requires explicit package name" error. This is triggered by use strict, not by -w.

    $ perl -Mstrict -le 'print $x' Global symbol "$x" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.

    The error we're dicsussing here is seen whenever you try to print a variable that contains "undef" (even if it's previously been declared). This is triggered by -w (or use warnings).

    $ perl -Mstrict -w -le 'print my $x' Use of uninitialized value in print at -e line 1.
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg