Works for me on the command line. Also works using most recent changes copied out of the script and into your test:

unless (&check_name($app{"first_name"})) { undef $app{"first_name"}; push (@errors, "Helpful message..."); }

It still doesn't work in CGI. I added use Data::Dumper and to the actual script and "Dumper" to the end of the &print_application function:

sub print_application { header, start_html, table({-border=>'0' -class=>'boxed'}, Tr( [ td([b('First Name:'), "$app{'first_name'}"]) ] ), p("Value is", $app{'first_name'}), pre( Dumper \@errors, Dumper \%app ), end_html; }

Oddly enough, this is what comes out the other side:

A form element with the value "nameCheckFailsIfNumbersPresent12345" in + a table, and... Value is # <- undef here has it should be. But not above? $VAR1 = [ 'Names must be between two and forty total characters, start + with an initial capitol, and may only contact alphabetical character +s, a dash, or an apostrophe.' ]; $VAR2 = '$VAR1 = { \'first_name\' => undef }; ';

That looks like it works, except this line from the same print_application function: print textfield(-name=>'first_name', -size=>'40', -maxlength=>'40', -default=>"$app{'first_name'}");

returns... <input type="text" name="first_name" value="nameCheckFailsIfNumbersPresent12345" size="40" maxlength="40">

Why is the value "nameCheckFailsIfNumbersPresent12345" present in $app{'first_name'} but not in Dumper \%app or p("Value is", $app{'first_name'}) - all of which are called from inside the function?


In reply to Re^4: 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.