Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Using non-scalar constructs in foreach loops

by Jasper (Chaplain)
on Mar 17, 2005 at 17:47 UTC ( #440457=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Using non-scalar constructs in foreach loops
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-09-23 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (224 votes), past polls