in reply to Strange problem with nested arrays and scoping.

There are probably some references assigned somewhere in the code -- perhaps a reference to the tempdata array is returned by the subroutine that creates it? What is the last line of that subroutine -- or include the whole thing, if it's not especially long.

The notation for array indexing is pretty bletcherous. They're taking scalar slices of arrays instead of indexing a scalar element. It would be much nicer to see $data[$sheet][$iC][$index] than ${${$data[$sheet]}[$iC]}[$index], which is at least sigil-correct for @{@{@data[$sheet]}[$iC]}[$index].


The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: Strange problem with nested arrays and scoping.
by Tyr_7BE (Initiate) on Dec 02, 2003 at 21:42 UTC
    Ahhhh...that did it. In the first subroutine, I had @{$data[$sheet][$iC]} = @{$tempdata[$sheet][$iC]}. I changed this to $data[$sheet][$iC] = \@{$tempdata[$sheet][$iC]} and screwed around with some references in the second subroutine, and it's correctly accumulating my value list. Thanks a lot everyone! I'm on my way again, and with a new knowledge of how (and how NOT) to reference arrays :) You live and learn.