in reply to Changling here?

Quite simply, because array slices are not arrays.

Consider the equivalent using a regular array instead of a ref:

my @states = ( [], [] ); my $aray_size = @states[1];
Even though we know that the element at $states[1] is an array, it doesn't matter; the slice is returning the single-element list ([]), and thus the scalar $aray_size receives the last element thereof - the (second, inner) arrayref.

What you need to do is make sure you've actually got the array-ref which is the second element of the (outer) array, dereference that, and subject that to the scalar() operator. Something like

my $aray_size = @{ ${$states}[ 1 ] }; # or my $aray_size = @{ $states->[ 1 ] };
(Note that the scalar op is implicit, due to the context transmitted by the assignment operator from the scalar variable on the LHS.)

A word spoken in Mind will reach its own level, in the objective world, by its own weight