http://www.perlmonks.org?node_id=11104829


in reply to Re^2: Suggestion on rewriting small code
in thread Suggestion on rewriting small code

I have adopted the convention of using $#... when I actually mean "index of the last element" and @... when I mean a "count" of elements. A very small advantage is that this does not depend on the default value of "$[". (I have not used that in since I got over my FORTRAN habits years ago)
Bill
  • Comment on Re^3: Suggestion on rewriting small code

Replies are listed 'Best First'.
Re^4: Suggestion on rewriting small code
by AnomalousMonk (Bishop) on Aug 21, 2019 at 20:04 UTC
    ... when I mean a "count" of elements.

    Yeah, I guess the multiplier really is "one less than the number of array elements". Thank you for satisfying my curiosity.

    ... the default value of "$[".

    In Perl 5, changes | assignment to  $[ have | has been increasingly constrained over the years and in the most recent versions are | is completely disabled, but I still can't help thinking when I write something like  0 .. $#ra to list all possible indices of an array that I should perhaps really be writing  $[ .. $#ra instead.


    Give a man a fish:  <%-{-{-{-<