in reply to Why is $. not zero-based?

Because back when they were putting line numbers in The Bible, computer scientists had not yet invented the fad of counting from 0. So why should Perl buck such a long tradition when it comes to line numbers?

Update

Although they call it "chapter and verse", "verse" means "line" or, as one dictionary put it, "a single metrical line in a poetic composition; one line of poetry".

And now that I've thought about it some more, I think a more interesting question is why we index arrays starting at 0. Well, that is controversial enough of a thing that Perl supported $[ to let you pick whether to start counting from 0 or 1.

Perl primarilly got the "index starting from 0" from C but C got that idea for a rather specific and obscure reason. In C, array[n] is just syntatic sugar for *(array+n) and it only makes sense for a pointer to point at the first element in its list. So it only make sense to use array[0] to reach the first element in this situation.

Note that this unnatural (pun intended) convention has lead to several problems by causing tension between the numbering humans expect and the numbering C expects. A good example of such problems is that localtime requires you to add one to the month number before you display it. Another is having to distinguish $#array from 0+@array in Perl.

Like most humans, I'd rather count from 1. Unlike some programmers, I'd also rather index starting at 1. I don't like having contention between indexing and counting. Even Perl starts counting from 1 when counting from the end of a list or string [ $array[-1] and substr($s,-1) ].

                - tye ("And now I'd like to quote from Revelations 0:0...")

Thanks to sauoq for reminding me that the deprecated special variable I was thinking of was $[ and not $#.