How to get array length in perl?

It’s as follows :

 

#!/uer/bin/perl

@array = (1,2,3);
$array[50] = 4;

$size = @array;
$max_index = $#array;

print "Size:  $size\n";
print "Max Index: $max_index\n";

O/P

Size: 51
Max Index: 50

Leave a Reply