Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Need advice on checking two hashes values and keys

by aaron_baugher (Curate)
on Jun 03, 2015 at 23:29 UTC ( [id://1129015]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Need advice on checking two hashes values and keys
in thread Need advice on checking two hashes values and keys

You're welcome. One way of doing it with a hash of arrays while maintaining the original order would be to save the line number in which you find each key together with its value. So your hash after the first loop would look like this:

$hash = ( uno => [ 1, 'uno' ], due => [ 2, 'dos' ], tre => [ 3, 'tres' ], # and so on );

Then after the second loop it would look like this:

$hash = ( uno => [ 1, 'uno','un' ], due => [ 2, 'dos','due' ], tre => [ 3, 'tres','tris' ], # and so on );

Then you'd need to learn how to sort the hash on the first element in each sub-array so that you can print them out in order. If you want to try that, then inside your first loop, you can get the line number to go with each key/value pair from the special $. variable.

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found