http://qs1969.pair.com?node_id=448836


in reply to Re^3: how many elements in array?
in thread how many elements in array?

bradcathey,
There are lots of ways in which $#array can be useful otherwise it wouldn't exist in the language. My point was more about correctness. For instance, if I am doing the following:
my @ucase = grep { $_ eq uc() } @words; my $cnt = @ucase;
I have the count of uppercase words, making all appropriate assumptions about @words. I would need to use $#ucase + 1* since it doesn't produce a count of elements otherwise. This was not clear from the post that I was replying to.

Cheers - L~R

* As RazorbladeBidet points out, modifying $[, is one highly discouraged way of accomplishing the same thing.