[英]Perl How to access a hash that is the element of an array that is the value of another hash?
[英]Perl array of hash with an element which might be another array of hash
假设我们具有以下数组结构:
push @active_connections, {
token => $token,
pending => VALID_WEBSOCKET,
time=>time(),
badge => 0,
monlist => $monlist,
intlist => $intlist,
last_sent=>{},
platform => $platform
};
稍后我要添加到last_sent中,以便last_sent将具有两个值,以及该ID的“ id”和一个“ value”,并且该值本身必须是一个列表。
换句话说,假设我的id = 1,2,3,并且关联值10,20,30我希望能够:
$active_connections[i]->last_sent{'1'} should return 20
$active_connections[i]->last_sent{'3'} should return 30
如何设置last_sent能够执行类似的操作?
谢谢
您不必“设置”任何东西。 只需取消引用有问题的值,剩下的就由自动生存完成。
$active_connections[$i]->{last_sent}->{1} = 20;
$active_connections[$i]->{last_sent}->{3} = 30;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.