I appologize for my ignorance, but I'm still new at this! I'm trying to write a multiple form survey but am running into 2 problem with my code. I most like have some wrong ideas about how certain things work. For any clarification I'll be most thankfull.
Problem 1.) The script proceeds to the 2nd form without me completeing the 1st.
Problem 2.) The 2nd form is upended at the bottom of the 1st, not in its own window.
#!/usr/bin/perl
for ( $i=1 ; $i<=2 ; $i++ ) {#loop over # of forms
&display_file ($i);
%box = &read_query_string; # Read keys and values
open(OFILE,">> temp.dat") || die "can't open output file:\n$!";
print OFILE "$box{'age'} \n";
close OFILE;
};
sub read_query_string
{
local ($buffer, @pairs, $pair, $name, $value, %FORM);
# Read in text
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else
{
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$FORM{$name} = $value;}
%FORM;
};
sub display_file
{
($nummer) = @_;
open (FILE, "< ../FPR/$nummer.htm" ) || die "can't read input file
+:\n$!";
print "Content-type: text/html", "\n\n";
while (<FILE>) {print;}
close (FILE);
};
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.