Arrays and negative indexes in Perl

前端 未结 3 1619
北荒
北荒 2021-01-12 17:48

I am newbie in Perl and I am reading about arrays.
As I understand the arrays expand automatically as needed (cool!)
But I also read that we can use neg

3条回答
  •  余生分开走
    2021-01-12 18:21

    If you read it, the result is the same as reading $array[5] — the value doesn't exist and you get an undef out. Going off the end to the left and going off the end to the right are the same.

    If you write it, you get an error. Arrays can only auto-extend to the right.

提交回复
热议问题