For Quality purpouses, PerlDiscuss - Perl Newsgroups and mailing lists 's mail 
on Thursday 29 January 2004 23:49 may have been monitored or recorded as:
> I have written my HTML code to where it uses POST to collect information.
> Where do I start to write a script that collects the data from the web
> site, places the input into a dbm file, then places a 1 next to it like an
> array? Some of the data in the file will have zeros, while the ones that
> are inputted in the site will have a 1.
>

HI, 

try the CGI.pm modul (http://search.cpan.org).

It takes care of all your IO stuff. Use it in OO fashion (like below) or even 
in function oriented fashion (like explaind at cpan).

-----snip-------

#!/usr/bin/perl
#input_getter.pl

use strict;
use warnings;
use CGI qw /standard/;

my $cgi = new CGI;      #new CGI object
my @params=$cgi->param; #get all params (that came via post or get...)

print $cgi->header,             #print a response
        $cgi->start_html('Results'),
        $cgi->h1('you entered:'),
        $cgi->start_ul;

foreach (@params) {             #I assume all you data come as 
                                        #param1=value1&param2=value2 format
                                        #no arrays returned (as for multiple select 
boxes and so)
  print $cgi->li("$_ => ",$cgi->param($_));
}

print $cgi->end_ul,
        $cgi->end_html;

------snap--------------

returns to the caller

------snip----------


Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; lang="en-US" 
xml:lang="en-US"><head><title>Results</title>
</head><body><h1>you entered:</h1><ul><li>email =>  [EMAIL PROTECTED]</li></ul></
body></html>

------snap------------

which looks pretty much like valid html.

However, as browsers only return parameters, for which values were entered, 
dont do something like using the foreach loop above in modified form to eter 
you data in a db, unless you have checked that all the parameters you expect 
are acctually there (by either doig it server side in your script or using a 
little ugly javascript client side).

Hope thats a start, Wolf




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to