Dec 3, 2013, 8:23 AM
Post #12 of 12
Re: [FishMonger] Extracting last octet from regex capture group possible?
[In reply to]
There is a difference between referring to the 3rd element vs the 3rd index, which is the 4th element.
You're simply not accounting for the contextual system within which the expression "3rd element" is being uttered--as if the term "3rd" is somehow categorical. It's actually worse than this. You're conflating two different n-based systems. Ordinality within English doesn't use "zeroth," but begins with "first." Perl, however, uses "zeroth." Thus, your using both English and Perl ordinality when referring to array elements.
Within a system, viz., Perl, whose ordinality uses "0th, 1st, 2nd, 3rd", $x is the third element of the array @x.
"To access the zeroth element of @friends, we write $friends." Source: On Perl: Perl for Students and Professionals
Give this, the third element would be accessed by $friends.
That difference is the cause of the common "off by 1" error.
Conflating English's and Perl's ordinality is the cause of this type of error.
(This post was edited by Kenosis on Dec 3, 2013, 8:45 AM)