#!/usr/bin/perl print "Content-type:text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n/ /g; # replace newlines with spaces $value =~ s/\r//g; # remove hard returns $value =~ s/\cM//g; # delete ^M's $FORM{$name} = $value; } open(OUTF,">>survey.out") or dienice("Couldn't open survey.out for writing: $!"); # This locks the file so no other CGI can write to it at the # same time... flock(OUTF,2); # Reset the file pointer to the end of the file, in case # someone wrote to it while we waited for the lock... seek(OUTF,0,2); print OUTF "$FORM{'name'}|$FORM{'email'}|"; print OUTF "$FORM{'howreach'}|$FORM{'rating'}|"; %boxes = ( "des" => "Website Design", "svr" => "Web Server Administration", "com" => "Electronic Commerce", "mkt" => "Web Marketing/Advertising", "edu" => "Web-Related Education" ); foreach $key (keys %boxes) { if ($FORM{$key} == 1) { print OUTF "$key,"; } } print OUTF "|$FORM{'comments'}\n"; close(OUTF); print <Thank You

Thank You!

Thank you for your feedback.

Return to our home page

EndHTML sub dienice { my($msg) = @_; print "

Error

\n"; print $msg; exit; }