Re: Scalar variable in void context before a loop



On 2008-10-20 13:03, Jürgen Exner <jurgenex@xxxxxxxxxxx> wrote:
markhobley@xxxxxxxxxxxxxxxxxxxxxxxxxxx (Mark Hobley) wrote:
In my professional perl programming guide, some of the examples put the
variable to be used as an iterator in void context before the loop. For
example:

$l;
for ($l = 0; $l < 10; $l++) {
print $l;
}

I am curious as to what reasons there are for doing this, because there
does not appear to be any mention of it anywhere within the book.

Of ocurse I don't know what the author was thinking. But _I_ would write
this as
for my $| (0..9) {
print $|;
}

I hope not.


Another question is why he would possibly want to assign 0 to 9 to the
autoflush variable.

A third question is why you use a font which apparently uses the same
glyph for the pipe symbol and the lower case ell.

hp
.



Relevant Pages

  • Re: Scalar variable in void context before a loop
    ... markhobley@xxxxxxxxxxxxxxxxxxxxxxxxxxx (Mark Hobley) wrote: ... variable to be used as an iterator in void context before the loop. ...
    (comp.lang.perl.misc)
  • Scalar variable in void context before a loop
    ... In my professional perl programming guide, some of the examples put the ... variable to be used as an iterator in void context before the loop. ...
    (comp.lang.perl.misc)
  • Re: Factoring iteration
    ... Now it's cool that the double-nested loop turns into just the one line ... grid iterator class, where the actual per-item action is a method, ... All masks with only one bit set represent a solution for that field. ... actually requires backtracking, unless you want to find all possible ...
    (comp.lang.forth)
  • Re: std::vector : begin, end and insert - Using Objects instead of ints
    ... When there's a choice, prefer preincrement to postincrement, because pre ... The thing is, efficiency can be measured objectively, while "readability" ... split the operation into two statements, e.g. when erasing a list iterator. ... certain kind of loop that omits stmt3 in a for-loop header when you decide ...
    (microsoft.public.vc.mfc)
  • Re: Generics and for each
    ... so the compiler has no way of matching the 'String' type of the loop ... I used 'String' to ... stands it fails because it doesn't know that the Iterator is a ...
    (comp.lang.java.programmer)