@{@array[1..3]} is a weird looking construct. @{ ... } is an array dereference operator. He needs a link, which is a type of scalar. But @array[ ... ] creates a list.
This is one of those situations where you need to remember a rule to evaluate a list in a scalar context. The rule says that there is no general rule. Each list operator does its job. In this case, apparently, the array slice operator used in a scalar context returns the last element of the list. @array[1..3] in the scalar context is the same as $array[3] .
As you noticed, this is not useful. Array segments are not intended for use in a scalar context
If you want to smooth the 2-dimensional structure of nested arrays into a 1-dimensional list, use map :
print join ' ', map { @$_ } @array[1..3]
You are still using the range operator for slicing. You just need some kind of loop construct (e.g. map ) to apply the array explode operator separately to each element of the external array.
source share