Jun 192010
Get array size in Perl
Answer:
To get the size of array in Perl, you have two methods.
Sample code:
my @a = (1, 2, ,3);
1. By scalar context
my $size = scalar @a;
2. By special variable $#array
my $size = $#a + 1;
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Get array size in Perl
Answer:
To get the size of array in Perl, you have two methods.
Sample code:
my @a = (1, 2, ,3);
1. By scalar context
my $size = scalar @a;
2. By special variable $#array
my $size = $#a + 1;