[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Example?



At 10:37 AM +0000 6/18/96, Nico.Rozendaal@NP.RULIMBURG.NL wrote:

>Hallo,
>
>I am new to this list. Does someone have a PERL example
>that will save (append, NOT overwrite) the fields of a form as a
>(tab-delimited) textfile ?

Here's one I wrote that seems to work pretty well for an online survey I'm conducting. Good luck!

#! /usr/local/bin/perl
push(@INC, "/cgi-bin");
require ("cgi-lib.pl");

# pull the variables out of the form and put them in an associative array
# called "input"

&ReadParse(*input);

# now, append these variables to a tab-delimited file, with a return at the end
# of each record. If the file "cmedata.txt" already exists, the data will be appended
# to it. If it doesn't exist, then it will be created and the data will be written to it.

open (DATAFILE, ">> cmedata.txt" );

print DATAFILE ("$input{'name'}\t");
print DATAFILE (" $input{'email'}\t");
print DATAFILE ("$input{'specialty'}\t");
print DATAFILE (" $input{'interested'}\t");
print DATAFILE ("$input{'topics'}\t");
print DATAFILE ("$input{'type'}\t");
print DATAFILE ("$input{'other'}\t");
print DATAFILE ("$input{'hours'}\t");
print DATAFILE ("$input{'otherhours'}\t");
print DATAFILE ("$input{'howmuch'}\t");
print DATAFILE ("$input{'otheramount'}\r");

close (DATAFILE);


--------------------------------------------------------------------
Michael L. Richardson, M. D.
University of Washington
Department of Radiology
Box 357115
Seattle, WA 98195-7115
voice: (206) 543-3320 / fax: (206) 543-6317
mrich@u.washington.edu
--------------------------------------------------------------------