I personally believe I may come out as an annoying little voice, but I have to join the chorus: that is a statement-modifier-for which happens to have the form of Perl-style C<for> acting on $_ - and saving you the need of parens. But by a (generic) Perl-style C<for> it is meant either:
for my $i (LIST) { ... } # or
for (LIST) { ... }
"C-style" is in no way bad "because of useless $i variable" since indeed there may not be any $i variable at all: it's "just" a completely different kind of loop altoghether (a more generic one - and that is fundamentally the reason why it exists at all,) which bears the same name as Perl-style one due to the fact that it can easily be disambiguated from the latter by means of the syntax of what's in the parens. I would go as far as claiming that what's in the parens itself in that case is yet another minilanguage (very closely related to Perl itself: it consists of exactly three Perl statements!) that does not fit in other parts of Perl's syntax, and thus a very special case: of course Perl 6 knows better and gives it an entirely different name which IIRC is C<loop> and not by chance takes one letter more wrt "for" since that's for huffmanization and in fact it is thought to be on a much sparser basis to begin with.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|