Creating an array reference to hash values

2019-07-20 04:18发布

问题:

Is it possible to return a hash's values as an array reference?

\@{values %hash}

I looked over the perlref document, but didn't see anything relating to this (or if I did, I wasn't able to relate it to my question).

回答1:

I think you're looking for this:

my $values_ref = [ values %hash ];


标签: arrays perl hash