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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Please with CGI/Perl Script

Status
Not open for further replies.

AmandaBurke

Programmer
Aug 24, 2000
6
CA
Hi,

I'm new to CGI/Perl programming and I'm having a lot of trouble with a script that I'm trying to get working. If some one could help me it would be great. Here is the code that I'm working on:

if ($ENV {'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach $pair (split(/&/, $buffer)){
($key, $value) = split(/=/, $pair);
$key =~ tr/t/ /;
$value =~ tr/t/ /;
$value=~s/%/([a-fA-F0-9][a-fA-F0-9]/pack("C", hex($1))/eg;
$parameters{$key} = $value;
}

open (TEMP, ">>/cgi-bin/temp.dat");
open (FILE, "/cgi-bin/helplog.dat");

while($line = )
{
if ($name eq $parameters{searchfor})
{
print TEMP $line;
}
}
close (TEMP);
close (FILE);








 
Well, from what I can see, there are a few problems:

First, in the %parameters hash, you have it called wrong, I guess is how you would say it. Saying $parameters{searchfor} does not work, instead, you have to say $parameters{'searchfor'}.

Second, the while($line = ) is something that I have never seen before. I am not sure what you are trying to do, but if you are trying to assign the scalar $line to the file, then you should do something like $line = <FILE>;.

I hope this helps, you should probably also post what is the error message you are getting.

Hope this helps.


-Vic
 
Thanks a lot for the help. I did get it working before your reply came in, although I'm not sure how. I'm now going to go back and look at the code some more. Once again thanks a lot for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top