in reply to Changling here?
@$states [ 1 ] is an array slice (see Slices). The syntax you require is my $array_size = @{$states->[1]}. Note that $array_size is a scalar so you don't need the scalar operator.