[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] "," instead of ";" in "for"



At 22:20 1999-08-27 +1000, Peta Adams - John Murray wrote:
...
>Change ";" to "," and you get
>
>print 'The names of lists we currently support are:',"\n";
>	for ($i = 0, $i < @lists, $i++) {
>	print $i;
>	print $lists[$i],"\n";
>}
>OUTPUT:
>The names of lists we currently support are:
>1arrangements
>1arrangements
>1arrangements
>
>Any thoughts on the sequence of events that occur to create this output?

Instead of the usual three parts in the 'for' brackets (init, test,
increment) you have only one, the initialisation. It uses the comma
operator to do three things one after another: it sets $i to 0, makes
a test in a void context and throws the result away, increments $i to
1, and uses that.

Peter.


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org