Oh don't worry - i ran the code serveral times. Again . What Is It Suppose To Do!!!!!

Sigh, at any rate, here is something for you to mess with:

use strict; use Data::Dumper; use CGI qw(header params); # this prints the content-type for you # you can use params() to get form values without # having to roll your own code print header(); my %INPUT = ( quizes => 2, assign => 2, recit => 2, ndays => 1, AT32000011 => 1, QZ132000011 => 1, RI132000011 => 1, AS132000011 => 1, QZ232000011 => 2, RI232000011 => 2, AS232000011 => 2, AT32000012 => 1, QZ132000012 => 12, RI132000012 => 12, AS132000012 => 12, QZ232000012 => 22, RI232000012 => 22, AS232000012 => 22, ); my %STUDQT; foreach (32000011..32000012) { push @{$STUDQT{$_}}, qw(fname mname lname Sex); } my @sorted = sort { "$STUDQT{$a}[3] $STUDQT{$a}[2] $STUDQT{$a}[0]" cmp "$STUDQT{$b}[3] $STUDQT{$b}[2] $STUDQT{$b}[0]" } keys %STUDQT; #Get The Inputs From User # remember, CGI can do this for you - see params() foreach my $l (@sorted) { my $STUD_1 = $STUDQT{$l}[1]; for my $i (1..$INPUT{'assign'} + 1) { if ($INPUT{"AS$i$l"}) { $STUD_1 = "$STUD_1$INPUT{\"AS$i$l\"}"; $STUD_1 .= "~" unless $INPUT{'assign'} == $i; } } $STUDQT{$l}[1] = "$STUD_1"."^"; print "key('32000011') is = $STUDQT{'32000011'}[1] <br>\n"; print "key{'32000012'} is = $STUDQT{'32000012'}[1] <br>\n"; }
Basically, i removed all instances of ['02'] ... i don't think that these do what you think that they do. Add them back and watch strict complain. Now, if i _knew_ what the GOAL was (hint hint) - i could give a better answer. But i am not going to play 'Guess my problem' any longer with this code.

jeffa


In reply to (jeffa) 3Re: associative array problem by jeffa
in thread associative array problem by Gerryjun

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.