Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Variable number of foreach loops

by ikegami (Pope)
on Nov 28, 2013 at 18:47 UTC ( #1064861=note: print w/ replies, xml ) Need Help??


in reply to Variable number of foreach loops

I have ... arrays a_1,a_2,a_3...a_N

That's oh-so-wrong. Always use use strict;, which specifically forbids this (among other things). You should use an array of arrays instead.

i need "variable" number of foreach loops based on variable "$count" Is this possible in PERL?

If you mean "Perl" and you fixed the error mentioned above,

use Algorithm::Loops qw( NestedLoops ); splice(@aoa, $count); NestedLoops(\@aoa, sub { print(@_); });

Or if $count == @aoa,

use Algorithm::Loops qw( NestedLoops ); NestedLoops(\@aoa, sub { print(@_); });

Algorithm::Loops


Comment on Re: Variable number of 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://1064861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2015-07-02 11:04 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 (34 votes), past polls