CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
form processing w/ time stamp



Jun 3, 2000, 4:53 PM

Post #1 of 3 (1507 views)
form processing w/ time stamp Can't Post

I have this script that writes to html the results of a form. but I want to add a time stamp of when the form was processed. Can someone help me rewrite this?

# Get the input data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Parse the data
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

# get rid of the % encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;

if(! $allow_html) {
$value =~ s/<([^>]|\n)*>//g;

$FORM{$name} = $value;

open(FILES, "$file") &#0124; &#0124; die "Can't open FILE: $file\n";
@files =<FILES>;

open(FILES, ">$file") &#0124; &#0124; die "Can't open FILE: $file\n";
foreach $line (@files) {
if($line =~ /<!--Begin Directory-->/i) {
if($top) {
print FILES "<!--Begin Directory-->\n";

print FILES "<tr><td align=center>$FORM{'artist'}</font></td><td align=center><em>$FORM{'song'}</em></td><td align=center><b>$FORM{'name'}</b></td><td align=center><a href=mailto:$FORM{'contact'}>$FORM{'do'}</a></td></tr>\n";

if(! $top) {
print FILES "<!--Begin Directory-->\n";
else {
print FILES "$line";


print "Location: $gto\n\n";


Jun 4, 2000, 8:51 AM

Post #2 of 3 (1507 views)
Re: form processing w/ time stamp [In reply to] Can't Post

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

$ptime = localtime();
print FILES "Processed $ptime\n";</pre><HR></BLOCKQUOTE>

Details of getting this into your table are left as an exercise.

By the way, the use of $top seems screwy, since you never set it. Also, you may have a dangling </font> tag in the table.

[This message has been edited by dws (edited 06-04-2000).]


Jun 14, 2000, 10:03 PM

Post #3 of 3 (1507 views)
Re: form processing w/ time stamp [In reply to] Can't Post

cailet use to parse you data.

print scalar localtime;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives