in reply to Re^2: Learning Perl - Question About Using a For Loop To Pull Data From an Array
in thread Learning Perl - Question About Using a For Loop To Pull Data From an Array

It seems that the name chosen, $counter, is confusing you.

It is being used as an INDEX, rather than as a traditional COUNTER.

The array is indexed from 0 to (n-1). (Updated to n-1)(Thanks, Corion)

You need to subtract one from the value entered, in order to get the equivalent index for a zero-based array.

Hopefully, that clarifies things.

FYI, Fred's friend is named Barney, not barnet. and Barney's kid is Bamm-Bamm.

        This is not an optical illusion, it just looks like one.

  • Comment on Re^3: Learning Perl - Question About Using a For Loop To Pull Data From an Array