http://www.perlmonks.org?node_id=1064863


in reply to Re^8: Variable number of foreach loops
in thread Variable number of foreach loops

I want to be able to call gen_loops() for multiple number of array elements.

I still do not understand what problem you are having?

If you want to call it with 3 arrays: call it with 3.

If you want to call it with 4 arrays; call it with 4.

If you ....

Instead of repeating the same thing over and over; try showing us what you are trying to do that isn't working.

Ie. DESCRIBE THE PROBLEM YOU ARE HAVING?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^10: Variable number of foreach loops
by abhay180 (Sexton) on Nov 29, 2013 at 05:31 UTC
    Dude, Not sure what i have repeated again and again..you asked for code...i showed you. Not sure how else you want to represent. The arguments i am passing to print_comb() function can create "variable" number of arrays. So i should be able to pass this variable-arrays to gen_loops(). I cannot have a static call like:
    gen_loops(2,\@array_1,\@array_2)
    and i want it like...
    gen_loops($count, < "$count" number of arrays>)
    Not sure if i am able to explain. Anyways i have figured it out in some round-about manner. Thanks for your help.

      Had the question been phrased as:

      I have a fixed number of arrays to permute, but I want to be able to pick a (sub)selection of those arrays at runtime using a string argument.

      Then I might have come up with something like:

      But then, if you'd taken the time to understand what you were trying to do, enough that you could express it clearly, you could probably have arrived at the solution yourself.

      FWIW: The problem you are having has little or nothing to do with how to call a subroutine, and everything to do with how to use or avoid symbolic references. (Read all three parts!)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Thanks for Pe(a)rl(s) of wisdom! I cannot agree more. Yes, i think i went too voyeuristic by using symbolic references instead of the usual hashes and array-of-arrays.