Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks for all the quick responses. I'll be sure to vote up a bunch of posts. I ventured over to the other thread and found this code. I don't really understand what is occurring, so I thought I could explain it to the best of my abilities, and you guys could help by filling in the gaps?

#! perl -slw use strict; my @a = 1..3; my @b = 'a'..'f'; my @c = map chr, 33 .. 37; nFor( 3, \@a, \@b, \@c ); #3 sets the number of arrays to sift through +. sub nFor { my $n = shift; #I understand shift chops off the first element in +an array, but what purpose does that serve? Also, how are the arrays + (@a, @b, @c) referenced in this code? if( $n ) { #what exactly is $n? for my $i ( @{ shift() } ) { # I have no idea how $i get's it' +s value? nFor( $n-1, @_, $i ); #why does the top nFor call for 4 va +riables, while this one only calls for 3? } } else { print join ' ', @_; } }
I love it when a program comes together - jdhannibal

In reply to Re^2: Dynamically create a foreach loop within a foreach loop? by jdlev
in thread Dynamically create a foreach loop within a foreach loop? by jdlev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others having a coffee break in the Monastery: (3)
    As of 2025-06-12 22:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.