[snip]

Hi Brian,

I usually deal with multidimensional arrays this way:

$i = 0;
while (@results = $sth->fetchrow_array ())
{
   $x = $results[0];
   $y = $results[1];
   @points = ($x, $y);
   $data[$i] = [EMAIL PROTECTED];
   $i++;
}

Just a note about a possible problem with the statement:
    $data[$i] = [EMAIL PROTECTED];

Everytime through this loop, the reference to @points, ([EMAIL PROTECTED]), is assigned to @data. But this is the same address. The result is that all the array refs assigned to @data are the same. So, the *last* assignment to @points, (x,y), will be the values for every element of @data.

A correct way to say it in your example would be:
        $data[$i] = [EMAIL PROTECTED];

Another would be to declare my @points in the loop, so that you have a fresh ref every time through the loop. Then you could say:
    $data[$i] = [EMAIL PROTECTED];

Chris


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to