#!/usr/bin/perl -w
#entry.cgi
use CGI qw/:standard/;
use FileHandle;
print header,
start_html('Title goes here');#feel free to change this
if (!param) {
print h1('header goes here'),
start_form(-action=>""),
"Enter name here", textfield('name')," i.e. andy selby",
p(),
"Enter your email addy if different from your name", textfield
+('email'),"\@youremailaddress.com",
p(),
"Monday",popup_menu(-name=>'monday',
-values=>['yes','no','probably','preferred']),#feel free to su
+ggest more p(),
"Tuesday",popup_menu(-name=>'tuesday',
-values=>['yes','no','probably','preferred']),
p(),
"Wednesday",popup_menu(-name=>'wednesday',
-values=>['yes','no','probably','preferred']),
p(),
"Thursday",popup_menu(-name=>'thursday',
-values=>['yes','no','probably','preferred']),
p(),
"Friday",popup_menu(-name=>'friday',
-values=>['yes','no','probably','preferred']),
p(),
"Saturday",popup_menu(-name=>'saturday',
-values=>['yes','no','probably','preferred']),
p(),
"Sunday",popup_menu(-name=>'sunday',
-values=>['yes','no','probably','preferred']),
p(),
submit,
end_form;
}else{
open (OUT, ">>availability.csv") or die "$!";#output to csv file
print OUT join ",", map { param($_) } qw/name email monday tuesday wed
+nesday thursday friday saturday sunday/;
print OUT "\n";
p(),
close OUT;
}
print "<a href=\"display.cgi\">click here to view results</a>";#redire
+ct doesn't work, keeps 302'ing
print end_html;
####################################################
#!/usr/bin/perl -w
#display.cgi
use strict;
use warnings;
use CGI qw/:standard :html3/;
print header;
print start_html('title goes here');#feel free to change this title
print h1('header goes here');
print CGI::start_table();
print caption('The Following people are available thus'),
print TR({},
th([
'Name', 'Email', 'Monday', 'Tuesday', 'Wednesday',
'Thursday','Friday', 'Saturday', 'Sunday'
]),
);
open(my $DOC, "<", "availability.csv") or die "$!";
while(<$DOC>) {
chomp;
my @fields = split /\s*,\s*/;
print TR({},
td([
$fields[0], $fields[1], $fields[2], $fields[3], $fie
+lds[4],
$fields[5], $fields[6], $fields[7], $fields[8]
]),
);
}
close $DOC;
print CGI::end_table();
print end_html();
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.