Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 wandering the Monastery: (4)
As of 2014-10-22 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (113 votes), past polls