in reply to Re^3: Array slices: beyond the end/ Assigning an empty list to a Hash slice
in thread Array slices: beyond the end/ Assigning an empty list to a Hash slice

It is the simplest way to distinguish between a slice from an empty list and a slice of a list of undefs. The former is FALSE, the latter is TRUE in a test.

Okay.

The slice returns you exactly the number of elements you asked it to return, not some unexpected or unpredictable smaller number.

False. You do get a smaller number of elements, i.e. 0, when all the slice indexes are beyond the end...as you pointed out:

...UNLESS the whole slice would have to be padded with undefs, in which case you get an empty list

So I think your first point is the only valid reason.

  • Comment on Re^4: Array slices: beyond the end/ Assigning an empty list to a Hash slice