Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of uninitialized value with eq, ne, chomp .. etc

Status
Not open for further replies.

jerehart

Programmer
Jun 10, 1999
61
US
Hey,

I am getting these weird warnings when I use comparisons (of strings) and work on strings. my script wasn't working so I did a perl -w myscript.cgi and I get warnings of the type:

Use of uninitialized value in string eq at readdata.pm line 6.

where that line is
(from readdata.pm line 6)
if ($ENV{'REQUEST_METHOD'} eq 'GET')

and I also get this from a bunch of things, like ==, split, join etc ....

the #! is correct, any ideas?
 
Your web server process runs with a different environment than your normal interactive shell. When a browser requests a cgi script, the web server updates several environment variables to reflect the incoming HTTP request, such as:
Code:
$QUERY_STRING
$CONTENT_LENGTH
$REQUEST_METHOD
etc..
The cgi script is a child of this web server process, and hence inherits its environment. Hence for your code sample above, the variable [tt]$ENV{'REQUEST_METHOD'}[/tt] is most likely the cause of your warning message.
Cheers, Neil
 
Thanks Neil,

That is the answer because when I finally ran the scripts with perl -wc myscript.pl my syntax came out fine.

Thanks again
Miah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top