in reply to Re^2: Compare hash with arrays and print
in thread Compare hash with arrays and print

Correct. The code is basically equivalent. We both reverse the hash and then find the keys of that reversed hash. Making a named array @keys is actually an extra step. I suppose if we wanted to, the whole right hand side of the "my @keys" line could go into the foreach() statement but, that could be obtuse.

I was trying to show the workings of the reverse in the most straightforward way possible (simple syntax). I updated post to show the Op how to easily use Dumper to print the reversed hash, which is little more obvious how to do when it has an assigned name (rhash).

  • Comment on Re^3: Compare hash with arrays and print