Re: `$#array` vs `scalar @array`

2018-01-29 Thread Chas. Owens
Luckily in these cases, the faster answer is also the clearest answer in either case. On Mon, Jan 29, 2018 at 5:32 PM Paul Johnson wrote: > On Sun, Jan 28, 2018 at 10:57:25PM +, Chas. Owens wrote: > > $#array is the index of the last element of @array, so it will be one > less > > than scala

Re: `$#array` vs `scalar @array`

2018-01-29 Thread Paul Johnson
On Sun, Jan 28, 2018 at 10:57:25PM +, Chas. Owens wrote: > $#array is the index of the last element of @array, so it will be one less > than scalar @array which is the number of elements in @array (since Perl > arrays start with index 0). Therefore, to get the number of elements, you > would ne

Re: `$#array` vs `scalar @array`

2018-01-28 Thread Chas. Owens
$#array is the index of the last element of @array, so it will be one less than scalar @array which is the number of elements in @array (since Perl arrays start with index 0). Therefore, to get the number of elements, you would need to add one to $#array, which makes scalar @array faster. To get th