I'm pretty certain that
Joost is correct at least as far as the specifications of how each construct is supposed to work.
I'd like to add that it's worth paying attention to the aliasing behavior in certain situations, where the loop iterator variable ($thing in this example)
for my $thing (@things) { # do stuff to $thing # }
is not a copy of the current element of @things but more like a reference (a magic one that does not need to be de-referenced). The side effects have bitten me in the past, before I learned better :)
Also, I've just been reading
Perl Best Practices by
TheDamian and chapter 6 (around pg. 100) goes in-depth on some of the techincal *and* psychological implications of different ways of using for and it's brethren.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.