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

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



At 22:20 +1000 1999.08.27, Peta Adams - John Murray wrote:
>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?

Imagine this instead:

  print 'The names of lists we currently support are:',"\n";
  @list = ($i = 0, $i < @lists, $i++);
  for (@list) {
    print $i;
    print $lists[$i],"\n";
  }

It is the same thing.  You have a list of three elements in the for loop,
and $i is set to 0 + 1 for each iteration (since it was only set once).

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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