Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

What would you want it to do?

  1. Iterate on two arrays in paralel:
    @name = qw(fred wilma barney betty); @color = qw(black red blonde black); for $k (0 .. @name - 1) { print $name[$k] . " - " . $color[$k] . "\n" +} # fred - black # wilma - red # barney - blonde # betty - black
  2. Move a sliding window on an array:
    @name = qw(fred wilma barney betty); for $k (0 .. @name - 2) { print $name[$k] . " - " . $name[$k + 1] . "\ +n" } # fred - wilma # wilma - barney # barney - betty
  3. Take the elements of the array in twos:
    @name = qw(fred wilma barney betty); for $k (0 .. @name/2 - 1) { print $name[2 * $k] . " - " . $name[2 * $k + + 1] . "\n" } # fred - wilma # barney - betty
  4. Iterate on an array of pairs:
    @data = (["fred", "black"], ["wilma", "red"], ["barney", "blonde"], [" +betty", "black"]); @color = qw(black red blonde black); for $rec (@data) { my($name, $col +or) = @$rec; print $name . " - " . $color . "\n" } # fred - black # wilma - red # barney - blonde # betty - black
Or perhaps even something you would normally do with two levels of loops, like iterating on each combination of two names.

In reply to Re: can we pass two variable to foreach loop by ambrus
in thread can we pass two variable to foreach loop by phemal

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, 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, 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?

    What's my password?
    Create A New User
    [ambrus]: Corion: I don't understand what you mean by protocol-only here. Can you explain why AnyEvent::HTTP is wrong for you? Are you a HTTP client or a server?

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (7)
    As of 2016-12-07 15:34 GMT
    Find Nodes?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:

      Results (130 votes). Check out past polls.