Perl and string array problem

#!/usr/bin/perl
my @arr=("hello", "how", "are", "you");
$l=length(@arr);
print $l;

This print 1.Why?
How can i print the array size = 4?
I want to store these in an array.

hello
how 
are
you

And then i want to access these element through indexing.
How can i do this?

print $#arr+1;

$#arr contains index of array's last element.

1 Like
% perl -le'
  my @arr = qw(hello how are you);
  $l = @arr;
  print $l;
  '
4
1 Like
print $arr[1]; #prints how
print $arr[3]; #prints you

I just knew about

$k=$#(@arr);

But $l=@arr even looks easier.

Done.