Arrays and negative indexes in Perl
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 negative indexes to access the arrays in reverse order. E.g. an array of 3 elements can be accessed as: $array[0] $array[1] $array[2] or $array[-1] $array[-2] $array[-3] (in reverse order). My question is what happens for values smaller than -3 e.g. $array[-5] ? Does the array expand or something? 回答1: If you read it, the result is the same as reading $array[5] ― the value doesn't exist and you