i have the following code in a form:
my ($k) = 1;
while ( $k < 10 ) {
print qq|<td> <INPUT TYPE="TEXT" NAME="fs[$k]" SIZE="2" VALUE="$in{'fs[$k]'}" MAXLENGTH="2"></td>\n|; ++$k;
}
print qq|</tr>\n|;after the form is submitted, i want to concatenate the nine scores fs[1] - fs[9] separated by a comma or a colon. i think the following code works:
but i would like something more elegant instead of typing each one. i tried this but it didn't work:
my ($k) = 1;
while ($k < 10 ) {
$in{'Front9scores'} .= $test[$k] . ':';
++$k
}
Code:
print qq|<tr><td>Scores:</td>|; my ($k) = 1;
while ( $k < 10 ) {
print qq|<td> <INPUT TYPE="TEXT" NAME="fs[$k]" SIZE="2" VALUE="$in{'fs[$k]'}" MAXLENGTH="2"></td>\n|; ++$k;
}
print qq|</tr>\n|;
Code:
$in{'Front9scores'} = $in{'fs[1]'} . ',' . $in{'fs[2]'} . ',' .$in{'fs[3]'} . ',' ......Code:
my ($test) = \@fs; my ($k) = 1;
while ($k < 10 ) {
$in{'Front9scores'} .= $test[$k] . ':';
++$k
}