1.2.4 复杂数据结构
$wife{"Jacob"} = ("Leah", "Rachel", "Bilhah", "Zilpah"); # 错误
$wife{"Jacob"} = ["Leah", "Rachel", "Bilhah", "Zilpah"]; # 正确
用[] 中括弧来将一个列表转换成一个标量。
$wife[0] = ["Leah", "Rachel", "Bilhah", "Zilpah"]; #正确
$wife = ["Leah", "Rachel", "Bilhah", "Zilpah"]; #错误
左边要写成 $wife{"Jacob"} 或 $wife[0] 表明 wife 是一个数组或散列,只有对数组或散列才能这样赋值。
访问方式用 $wife{"Jacob"}[0] 或 $wife[0][0] 阅读全文 >>