Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Force access a Hash ref as Array ref

by tobyink (Canon)
on Jul 20, 2021 at 06:45 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found