[Techtalk] [Perl] cgi.pm - save input in .html file
Chris Henderson
hendersochris at gmail.com
Tue Jan 9 11:59:39 UTC 2007
I created a cgi file (test.cgi) which takes user input and shows at
the bottom of test.cgi. I want the result to be saved to a .html file
so the other people can view the result. I understand that I need to
open a file handle and somehow write the input from test.cgi to that
file handle but I am not too sure how. Here's my code -
#!/usr/bin/perl
use CGI qw(:standard);
print header;
print start_html('Test Form'),
h1('A Test Form'),
start_form,
"What's your name? ",textfield('name'),
p,
"What's your favorite mail client?",
p,
checkbox_group(-name=>'words',
-values=>['mutt','mail','pico','sylpheed'],
-defaults=>['mutt','mail']),
p,
"What's your favorite editor? ",
popup_menu(-name=>'editor',
-values=>['emacs','vi','ed','cat']),
p,
submit,
end_form,
hr;
if (param()) {
print
"Your name is",em(param('name')),
p,
"The keywords are: ",em(join(", ",param('words'))),
p,
"Your favorite editor is ",em(param('editor')),
hr;
}
print end_html;
Thanks.
Chris.
More information about the Techtalk
mailing list