Here is another sample using CGI::Ex::App. It behaves identical to the examples the OP provided in the tarbar. There is very little actual code to be written - and if we wanted to take it further we could move the validation and stick it out in a yaml file, and we could take the template and stick it out in a .html template file. Then the CGI would be really short. It can be viewed at http://iterpret.com/cgi-bin/perlmonks_615215.pl.
#!/usr/bin/perl use warnings; use strict; use base qw(CGI::Ex::App); __PACKAGE__->navigate; sub main_hash_validation { return { 'group no_alert' => 1, 'group no_confirm' => 1, member_type => {required => 1}, member_name => {required => 1}, member_address => {required => 1}, company_size => {required => 1}, member_phone => { required => 1, match => 'm/^\(\d{3}\) \d{3}\-\d{4}$/', match_error => 'Please type the phone number in (888) 555- +1234 format', }, }; }; sub main_finalize { my $self = shift; $self->add_to_swap(it_validates => 1); return 0; } sub main_file_print { return \ <<'DOC'; <html> <style>span {color:red}</style> <head> <title>FormWireframe</title> </head> <body> <h2>Simple Form Wireframe</h2> <blockquote> <form method=post name=[% form_name %]> <table> <tr> <td align=left valign=top colspan=2> <h3>Add/edit member</h3> </td> </tr> <tr> <td align=left valign=top colspan=2> <h4><font color=red>*required fields</font></h4> </td> </tr> <tr> <td align=left valign=top> Member Type* </td> <td align=left valign=top> <input type=radio name=member_type value=organization> Organization <input type=radio name=member_type value=individual> Individual <span id=member_type_error>[% member_type_error %]</span> </td> </tr> <tr> <td align=left valign=top> Member Name* </td> <td align=left valign=top> <input type=text size=30 name=member_name> <span id=member_name_error> +[% member_name_error %]</span> </td> </tr> <tr> <td align=left valign=top> Member Address* </td> <td align=left valign=top> <textarea name=member_address rows=4 cols=30></textarea> <span id=memb +er_address_error>[% member_address_error %]</span> </td> </tr> <tr> <td align=left valign=top> Phone* </td> <td align=left valign=top> <input type=text size=20 name=member_phone> <span id=member_phone_erro +r>[% member_phone_error %]</span> </td> </tr> <tr> <td align=left valign=top> Company Size* </td> <td align=left valign=top> <select name=company_size> <option></option> <option>Over 20,000</option> <option>Over 10,000</option> <option>Over 5,000</option> <option>Over 1,000</option> <option>Under 1,000</option> </select> <span id=company_size_error>[% company_size_error %]</span> </td> </tr> <tr> <td align=center valign=top colspan=2> <input type=submit name=submit value=Submit> </td> </tr> </table> </form> [% js_validation %] </blockquote> [% IF it_validates %] <h2>Congrats! This form validates completely!</h2> [% END %] <a href=[% script_name %]/source>Source for this file</a> | <a href=ht +tp://perlmonks.org/?node_id=615215>Perlmonk node 615215</a> </body> </html> DOC } sub source_run_step { shift->cgix->print_content_type('text/plain'); open(my $fh, "<", __FILE__) || die; print <$fh>; return 1; }


my @a=qw(random brilliant braindead); print $a[rand(@a)];

In reply to Re: Dynamic Language questions by Rhandom
in thread Dynamic Language questions by talexb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.