for my $word ( keys %{ $hash{ $w1 }{ $w2 }{ words } } ){ push @wordsList, ($word) x $hash{ $w1 }{ $w2 }{ words }{ $word }; }