perl change ref of hash

前端 未结 3 1554
眼角桃花
眼角桃花 2021-01-25 07:13

I ran into this and couldn\'t find the answer. I am trying to see if it is possible to \"change\" the reference of a hash. In other words, I have a hash, and a function that ret

3条回答
  •  粉色の甜心
    2021-01-25 08:12

    Sounds like you want:

    use Data::Alias;
    alias %hash = $h->hashref;
    

    or if %hash is a package variable, you can instead just do:

    *hash = $h->hashref;
    

    But either way, this should almost always be avoided; why don't you simply use the hash reference?

提交回复
热议问题