All I want to do it is read some form data.!! I'm not a perl programmer so this is doing my head in. Anyway, I have the sub below:
# A simple HTTP request parser to emulate ASP request.xxx< # So you can do $request->{"clicked"} in place of Request("clicked") # Has problems with MIME or complex submits # sub getHTTPData { my $xx; my $buffer; my %vars; if($ENV{"REQUEST_METHOD"} eq "GET") { $buffer=$ENV{'QUERY_STRING'}; } else { read ( STDIN, $buffer, $ENV{"CONTENT_LENGTH"}); } foreach $pair (split(/&/, $buffer)) { $pair =~ tr/+//; ($name, $value) = split(/=/, $pair); $value =~ s/%(\w\w)/sprintf("%c", hex($1))/ge; # convert hex t +o ascii $value=~s/\+/ /g; $vars{$name}="$value"; } return \%vars; }
so that I can use $uid = $request->{"uid}";

Fair enough. I also want to be able to access all the items submitted in a form. So I tried to use this bit of code as well:

use CGI ':standard'; print "Content-type: text/html\n\n"; print "<body>"; foreach my $name ( param() ) { my @values = param ($name); print "<p><b>Key:</b> $name <b>Value(s):</b> @values"; }
That works fine. BUT if I use the following after the above code:
$request = getHTTPData(); print "<br> fromtime is ". $request->{"fromTime"};
I get nada! Only one way will work (whichever is used first on the page)... am i asking to much to be able to do the equivalent of:
for each fld in request.form # do stuff with the name and value next
Ideally something in the sub getHTTPData() would probably be best. Any suggestions? (and I thought Lotus Script/ Domino was opaque...). Thanks,
p.s. Is it possible to make variables on the fly from names/ values submitted from a form i.e. if there are fields name id, acc1, acc2 ..accn can I do something like this (in pseudo code)
foreach fld in formdata{ make a variable named $fld have a value of $value }
that I can then access later in the page?..;-)

Edit by tye: title, READMORE


In reply to reading CGI form data by markhoy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.