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!

perl5 variables - initialisation

Status
Not open for further replies.

pgmm

Technical User
Apr 18, 2001
8
IT
I am a learner
I have a small 15 line programme that will not compile.
Error message is "use of unitialised value" at line...
The line is:
@NameValuePairs = split (/&/, $QueryString);

and is preceded by:
$QueryString =$ENV{ 'QUERY_STRING'};

I have been struggling with this beginners problem for some time and would be very grateful for some guidance as to what is going wrong.
Thanks
 
I may be barking up the wrong tree here, are you running the script from the command line, or via a browser? And the script is being called with an actual query string
(script.pl?var1=23&var2=45)?

Other than that, the code you have shown above looks ok to me, I'll play around with it a bit and see if there is anything else I can find....
 
Arion 23 - thank you for your reply.
When run from the browser it just gives the usual error message about the server not processing.(The server is set up so it runs with the -w switch.)
I am getting the not initialised message from the command line.If you have time the complete script looks like this:
#!/usr/bin/perl -w
require "$Title = "Get information from a URL";
$QueryString =$ENV{ 'QUERY_STRING' } ;
@NameValuePairs = split (/&/, $QueryString);
&HTML_Header ($Title);
print &quot;<body>\n&quot;;
print &quot;<h1>$Title</h1>\n&quot;;
print &quot;<hr>\n&quot;;
foreach $NameValue (@NameValuePairs)
{
($Name, $Value) = split (/=/, $NameValue);
print &quot;Name = $Name, value = $Value<br>\n&quot;;
}
&HTML_Ender;
where HTML_Header and Ender are subroutines and the file is loaded to the browser cgi bin.

I am sorry to have to ask but perhaps this does &quot;fit the bill&quot; as far as the query string is concerned.

Thank you for your time and expertise!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top