On Monday, April 15, 2002, at 11:31 AM, Bill -Sx- Jones wrote:
> On 4/14/02 7:34 PM, "Ken Williams" <[EMAIL PROTECTED]> wrote:
>>  Code A:
>>       my $i;
>>       my $n = scalar @array;
>>       for ($i = 0; $i < $n; $i++) {
>>         $array[$i]++;
>>       }
>>
>>  Code B:
>>       foreach (@array) { $_++ }
>
>
> Do my vars suddenly spring into existence now?

Huh?  I'm not sure what you mean.  If you don't indicate an 
iterator variable, $_ will be used, and its scope will be 
localized to the execution block of the 'foreach' loop.

See the section on "Foreach Loops" in the 'perlsyn' man page for 
the details.

  -Ken

Reply via email to