http://www.perlmonks.org?node_id=440457


in reply to Using non-scalar constructs in foreach loops

I've written foreaches using array refs, hash refs, objects, you name it. The fact that a foreach must use a scalar value (ie a string or a ref or whatever) does not limit the amount of data that you can effectively pass in via that scalar.

I see from your code that you've already considered that, but it's not entirely clear in my mind what you're trying to do. It seems to me that what you ought to be trying is to create an unitialised multi-dimensional array, then foreaching through slices through the array and assigning values that way. A slice one way is trivial @{$array[0]}[foo..bar], the other way slightly more complicated map $array[$_]->[0], foo..bar, perhaps.

Since I've not grasped what you want, I'm probably rambling.