Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Force access a Hash ref as Array ref

by tobyink (Canon)
on Jul 20, 2021 at 06:45 UTC ( #11135197=note: print w/replies, xml ) Need Help??

in reply to Force access a Hash ref as Array ref

"I know that's not an ARRAY ref, but since I want to learn the appear order"

Hashes in Perl aren't ordered. As soon as you put things in a hash, whatever order the keys and values were listed in has already gone.

The workaround you describe is the best option. Passing a tied hash which maintains order is also a possibility, but results in more work for your caller, and slower performance.

  • Comment on Re: Force access a Hash ref as Array ref

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135197]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2021-10-22 03:56 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (85 votes). Check out past polls.