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

cool. nice explanation and advice on attack.

your number 3 seems to be a little more advance where I am but I think I want to use this method. I see alot of potential here. although, the numerical ordering is nice, I think putting it in this form will make me practice more difficult hashes then, after, I can practice on order.

so... more questions will follow on this 3rd type of exercise...thanks all for the help and advice.

  • Comment on Re^2: Need advice on checking two hashes values and keys

Replies are listed 'Best First'.
Re^3: Need advice on checking two hashes values and keys
by aaron_baugher (Curate) on Jun 03, 2015 at 23:29 UTC

    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.