Sunday, July 17, 2011

finding no of array elements perl

Content of the perl file:

@array=("hello","aaaa","lll","ggg");
print "The no of elements in the array is ".scalar(@array)."\n";
#it can also be done by this way
$no=@array;
print "The no of elements in array is ". $no;

Output:

G:\perl_programs>perl perl_array_no.pl
The no of elements in the array is 4
The no of elements in array is 4


G:\perl_programs>

No comments:

Post a Comment