Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 musing on the Monastery: (13)
As of 2015-07-05 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls