Guest_imported
New member
- Jan 1, 1970
- 0
Hello,
I had thrown together a small script which would take the number a person would enter into a form and open up the corresponding file and spit it out. The files are .WRI files, and I had it working about a year ago and have lost it since. Now trying to duplicate what I did then, I find myself pulling my hair out. At one point I had it reading the first line, but nothing else, now it's at the point where I get an internal server error, and I'm ready to go get an asp book and start learning that. lol Anyways, here is the current code, any help would be greatlty appreciated.
#!/usr/local/bin/perl
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~s/<--(.|\n)*-->//g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
open(MYFILE, "<$formdata{$key}.WRI"
;
my(@lines) = <MYFILE>;
my($line);
foreach $line (@lines)
{
$displayfile=<MYFILE>;
}
print "Content-type: text/html\n\n";
foreach $key (sort keys(%formdata)) {
print "<P><B>$displayfile</B>";
}
I had thrown together a small script which would take the number a person would enter into a form and open up the corresponding file and spit it out. The files are .WRI files, and I had it working about a year ago and have lost it since. Now trying to duplicate what I did then, I find myself pulling my hair out. At one point I had it reading the first line, but nothing else, now it's at the point where I get an internal server error, and I'm ready to go get an asp book and start learning that. lol Anyways, here is the current code, any help would be greatlty appreciated.
#!/usr/local/bin/perl
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~s/<--(.|\n)*-->//g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
open(MYFILE, "<$formdata{$key}.WRI"
my(@lines) = <MYFILE>;
my($line);
foreach $line (@lines)
{
$displayfile=<MYFILE>;
}
print "Content-type: text/html\n\n";
foreach $key (sort keys(%formdata)) {
print "<P><B>$displayfile</B>";
}