> I have this statement 
> if ( $ENV{REQUEST_METHOD} eq "GET")
> {
> .......
> .......
> }
> 
> That works fine if I don't use -w , but if I use  -w, 
> it tells "Use of uninitialized value in string eq at....."
> why?

Enviroment variables come via the shell (or CGI server), and
you can't trust them.  Certainly it's okay to do basic stuff
like this, but remember it *might not* be any of the values
you expected.

Because you are running from the shell (I think), you'll get
that because the ENV variable hasn't been set.  You should
do something similar to:

$ENV{REQUEST_METHOD} = "GET"
    unless defined $ENV{REQUEST_METHOD};

and remember to deal with the case it's neither GET or POST.
E.g.

if ($req eq "GET") {
    # Get
}
elsif ($req eq "POST") {
    # Post
}
else {
    die "Recieved unknown request method: @{[ substr($req, 0, 50) ]}\n"
}

The substr will ensure that you the enviroment variable can't be too large.  If you 
were security
paranoid you'd also remove all non word characters, replacing them with a marker for 
invalid
characters.  If you are more like everybody else, don't bother.

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to