ddrumguy has asked for the wisdom of the Perl Monks concerning the following question:
see below
#!/usr/bin/perl print "Content-type:text/html\n\n"; $diskuse = (system `/usr/bin/df -k`); 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; $FORM{$name} = $value; } # Since the "how you reached this site" list was saved as # a number, we need a hash to translate it back to English: %howreach = ( 0 => "", 1 => "$diskuse", 2 => "Site is bookmarked", 3 => "A search engine", 4 => "A link from another site", 5 => "From a book", 6 => "Other" ); print <<EndHTML; <html><head><title>Results</title></head> <body> <h2>Results</h2> Here's what you entered:<p> Your name: $FORM{'name'}<p> Email: $FORM{'email'}<p> Which option you picked: $howreach{$FORM{'howreach'}}<p> How you'd rate this site (1=poor,5=excellent): $FORM{'rating'}<p> EndHTML %boxes = ( "des" => "Website Design", "svr" => "Web Server Administration", "com" => "Electronic Commerce", "mkt" => "Web Marketing/Advertising", "edu" => "Web-Related Education" ); print "You're also involved in the following:<br>\n"; foreach $key (keys %boxes) { if ($FORM{$key} == 1) { print "$boxes{$key}<br>\n"; } } print <<EndFoot; <p> Your comments:<br> $FORM{'comments'}<p> </body></html> EndFoot
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running programs via cgi
by davis (Vicar) on May 10, 2002 at 16:49 UTC | |
|
Re: Running programs via cgi
by Silicon Cactus (Scribe) on May 10, 2002 at 17:54 UTC |