我有一个子程序,它获取作为参数的哈希引用。
用Perl中的hashreference替换哈希?
我可以通过引用操纵单个哈希值。 我想要替换整个散列,它的参考点在,以至于无处不在,在这个散列引用的地方,这些更改变得可见。
sub replace{
my $hashref = shift;
# can manipulate hash here
$hashref->{key} = "newValue";
# how to replace replace the hash here by a new hash
$newHashRef = {
key => "value",
key2 => "value2",
};
}
这可能吗?