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


in reply to Get the length of a list.

Another way, though not necessarily better than the original.

print scalar map $_, (1, 2, 3, 4, 3, 2, 1);
But if other processing is going to be done with the list, might as well just make a named array out of it from the start.