Re: Quirky behavior with for loop

2003-02-11 Thread Simon Oliver
 My abridged code is below.  What am I doing wrong, please?  I can't

see it.

Without any data it's hard to tell, but there are a few things that could 
be a problems.

First off, you haven't used strctures or -w.
Declare your variabes with my() contructs.

foreach $i (1..scalar(@question)) {


perhaps this should be (hard to tell without seing the data)
 foreach $i (0..scalar(@question)-1) {




		$these_rows=$question_values[$i];

...

		foreach $fg (0..($these_rows)-1) {


I assume that @question_values contains numeric values for each 
$question[n] - this could be the cause of your trouble.  (hard to tell 
without seing the data)

$columnar_chart_value=value_.$i._.$inner_counter._.$counter;


At no point do you declare or set $counter.

The final curly bracket is unmatched - perhaps a cut and pace problems?

--
  Simon Oliver

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Quirky behavior with for loop

2003-02-10 Thread Brad Smith
I have spent a good part of today trying to figure out a very simple situation 
where there are nested for loops.  Normally, I have not had problems, but, 
for some reason, with this tertiary level loop, Perl decides it just doesn't 
exist.  My abridged code is below.  What am I doing wrong, please?  I can't 
see it.

The strangest part of this whole dilemma is that I can test the variable for 
their content just before calling the last two 'for' loops, seeing that their 
values are as expected, but then the innermost for loop fails.

code below

foreach $i (1..scalar(@question)) {
if ($question_type[$i] eq columnar_chart) {


@names=split (/\|/, $question_answers[$i]);
$columns=scalar(@names);
$these_rows=$question_values[$i];

print qq~

abridged for emailing

   ~;

   $column_width=sprintf(%.1d,100/$columns);

foreach $k (0..($columns)-1) {
print qq~
td align=center width=$column_width%font face=Arial 
size=2 color=#33$names[$k]/font/td
~;
}

foreach $fg (0..($these_rows)-1) {
print We get to the outer loopbr;
print tr;
my $inner_counter=1;


foreach $rt (0..($columns)-1) {
print We get to the inner loopbr;

$columnar_chart_value=value_.$i._.$inner_counter._.$counter;

print qq~
td width=$column_width\%p align=centerinput 
type=text size=15 name=$columnar_chart_value/td
~;

$inner_counter++;
}

print /tr;
}
}
}
}

code above

Thanks in advance.

Brad Smith
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs