### Comment on

 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

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.
• 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and the monastery is silent...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2018-05-21 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (151 votes). Check out past polls.

Notices?