Sigh, at any rate, here is something for you to mess with:
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.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"; }
jeffa
In reply to (jeffa) 3Re: associative array problem
by jeffa
in thread associative array problem
by Gerryjun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |