Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: how to make a foreach loop dynamic?

by BioLion (Curate)
on May 20, 2010 at 11:37 UTC ( [id://840903]=note: print w/replies, xml ) Need Help??


in reply to how to make a foreach loop dynamic?

Your reading in of the options file doesn't care how many options (or elements in each option) there are. I take it you want to replace your three-tier foreach loop? There are many modules for this sort of thing on CPAN, and also there is some example code on perlfaq4.

The last example shows how to compute permutations for any array. HTH.

Just a something something...

Replies are listed 'Best First'.
Re^2: how to make a foreach loop dynamic?
by jaydot (Novice) on May 21, 2010 at 07:41 UTC

    thanks for the replies but im findin it hard to go on the sample code on perlfaq4.. i have trouble with understanding it. you see this is my first time creating a code like this.perl is my fist programming languange. and im having a hard time in doing all the coding..i have been starting the coding nearly two weeks already..and im a newbie to programming.. a little example will do just to guide me somehow..tnx in advance..

      Mayeb have a look at the source code for List::Permutor ( Source ). It is pretty well commented and should help.

      I would just use this module or similar to do the heavy lifting directly rather than trying to roll my own (Yes, even you can use CPAN) .

      Sorry I can't be of more help, time is short for me, but i hope you get this sorted out! I think the key lies in the way List::Permutor handles a list of *any* length, as opposed to your static three-tier loop. Have a look at that and see how you get on.

      Again, sorry I can't be more help.

      Just a something something...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found