This should be enough of the code to let you see the complete picture. Hopefully I didn't miss anything important.

#!perl.exe use strict; use warnings; use CGI qw(:standard -no_xhtml); # the check_name, etc, functions are in this require'd file except in # this example code # require "D:/Inetpub/wwwroot/gpa/functions.pl"; my @errors; my %app; $app{"first_name"} = param('first_name'); $app{"telephone"} = param('telephone'); $app{"email"} = param('email'); # Verify the POST data (if any) using custom tests and undef bad # values. If everything checks OK, accept the data and print a # success message. Else print the application form (which will # preserve all good values which users will appreciate. if (request_method() eq "POST") { my $first_name_check = &check_name($app{"first_name"}); unless ($first_name_check == "1") { undef $app{"first_name"}; push (@errors, "First Name: ".$first_name_check); } my $phone_check = &check_phone($app{"telephone"}); unless ($phone_check == "1") { undef $app{"telephone"}; push (@errors, "Telephone: ".$phone_check); } my $email_check = &check_email($app{"email"}); unless ($email_check == "1") { undef $app{"email"}; push (@errors, "E-mail: ".$email_check); } if (@errors) { # Give the user another chance. &print_application; } else { # Done! &print_accepted; } } else { # Give the user an application form. &print_application; } # We want first and last names to be a certain way. sub check_name { my $name = $_[0]; if ($name =~ /^[A-Z][A-Za-z\-']{2,40}/s) { return 1; } else { return "Helpful message."; } } # Chopped other subs to shorten post sub check_phone { return 1; } sub check_email { return 1; } # Print account application page. sub print_application { # chopped lots of non-relevant code... # here's those helpful error messages regarding BAD data... if (@errors) { print h2("Account Application Error"), "\n\n", p(b("Problems found...")), "\n\n", ol(li[@errors]), "\n\n"; } # print the form and populate form with GOOD data... # Avoiding line wraps in on-line post. n/b the funny indents :-) Tr( [ td([ b('First Name:'), textfield(-name=>'first_name', -default=>"$app{'first_name'}") ]), td([ b('Organization:'), textfield(-name=>'organization', -default=>"$app{'organization'}") ]), td([ b('Telephone:'), textfield(-name=>'telephone', -default=>"$app{'telephone'}") ]), td([ b('E-mail:'), textfield(-name=>'email', -default=>"$app{'email'}") ]), td([ '', submit ]) ] ) } # Print account accepted page. sub print_accepted { # ... }

In reply to Re: Changing the Value Assigned To A Hash Key by gnurob
in thread Changing the Value Assigned To A Hash Key by Anonymous Monk

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.