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

CGI

Status
Not open for further replies.

samesale

Programmer
Joined
Sep 15, 2003
Messages
133
Location
US
I am trying to pass on value to this file and then store them as variables. However, I tried to print the values to see whether they work. I do not get any output.

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {

($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", ex($1))/eg;
$FORM{$name} = $value;

}

foreach $key (keys(%FROM)) {
print "$key = $FORM{$key}<br>";
}

Please keep in mind that there are other parts of the program in the same program that work.
 
Assuming you're using this in a web environment, and even if you're not, have a look at CGI.pm, it makes all this transparent and easy

What do you get if you add these lines
Code:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
[COLOR=red]print "$ENV{'CONTENT_LENGTH'}\n\n";
print "$buffer";[/color]
@pairs = split(/&/, $buffer);

Have you syntax checked your script? at the command line
Code:
perl -c scriptname.pl


HTH
--Paul

 
Thanks for your help. I did try your suggestion. I get 56 as a print out.
 
Code:
56
if your output is as above, then nothing is being read in to $buffer.

IF you know the names of the variables

Code:
use CGI qw/:standard/;
use CGI::Carp (fatalsToBrowser);
$variable1=param('var1');
$variable2=param('var2');

HTH
--Paul
 
Code:
#!/usr/bin/perl

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", ex($1))/eg;
  $FORM{$name} = $value;
}

foreach $key (keys(%F[red]OR[/red]M))  {
  print "$key = $FORM{$key}<br>";
}


Kind Regards
Duncan
 
The value of photo is not passed on. It is read from a file and is working.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top