get the length of a perl array
December 5th, 2006 by Lawrence David
perl sometimes is just too easy. so easy that it’s confusing.
for instance, to print the length of an array @my_array, you don’t need a length command or anything. instead, just code:
print @my_array;
(no way i’m ever going to remember a command that simple.)
Yes, you got this wrong.
“print @array” actually prints the contents of the array, not the length.
Agreed, this will print the contents of the array, not the length.
Hi,
I think you can do something like this to get the length of an array:
my $length;
$length = @my_array;
print $length;
Really perlish.