Unable to store array as a hash value

后端 未结 2 1091
孤城傲影
孤城傲影 2021-01-27 03:29

I\'m trying to store an array (not array ref) in a hash but it is treating the array in scalar context and only storing the last value of array in the $hash->{

2条回答
  •  野的像风
    2021-01-27 04:08

    $h->{'a'} = [ 'str_1', 'str_2' ];
    

    You can only store scalar as a hash value, and scalar can be simple value or array reference.

    Check perldoc.

提交回复
热议问题