Your $arr
is an array reference. You need to dereference it with the @{ … }
operator: @{ $arr }
or the shorthand @$arr
.
my $arr = getArray();
print "Array : @$arr";
my $size = scalar @$arr;
print "Size : $size";
To access one element: ${ $arr }[0]
or the shorthands $$arr[0]
or $arr->[0]
, of which the last form should be preferred.
To learn more about Perl references, read perldoc perlreftut
.