in reply to Using foreach to iterate through a hash in an array

my @bla = (%hash, %hash2); doesn't create an array of hashes, it flattens the hashes to key - value pairs, so @bla in fact contains
"00:20:00", "a", "10:00:00", "b", "00:00:00", "a",
etc. (in no particular order).

To create an array of hashes, use references:

my @bla = (\%hash, \%hash2);

You can then iterate with dereference

for (keys %{ $bla[0] }) {

or, in recent Perls,

for (keys $bla[0]->%*)

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Using foreach to iterate through a hash in an array
by Anonymous Monk on Aug 30, 2017 at 11:36 UTC
    Oh ok thank you. It works and it seems as if I have skipped a few tutorial pages. I will have to take another look into it and thanks again.
      I have tried iterating with foreach and the hash itself

      foreach (keys $hash){
          print $_ . "\n";
      }

      So far so good ...

      Given the code you OPed, it's hard to imagine this would have done anything "good" unless  $hash.was actually a hash reference. If this was the case, please be aware of this from the latest Perl documentation:

      Starting with Perl 5.14, an experimental feature allowed keys to take a scalar expression. This experiment has been deemed unsuccessful, and was removed as of Perl 5.24.
      This experimental ex-feature was also associated with values, each, push, pop and friends.


      Give a man a fish:  <%-{-{-{-<