I prefer the following
my @Array = (1,2,3,4); say 0+@Array; #@Array as a number)
Its clearer than
say scalar(@Array); #@Array as a scalar)If you just want to print the size, this is the simplest way.
print "size of array: " . @array . ".\n";In reply to Re: Counting elements in array
by vinoth.ree
in thread Counting elements in array
by finfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |