in reply to looping through a hash and looking up values from another hash

This approach handles all the lines.
use strict; use warnings; my %hash1 = ( 1 => [qw( You Me Him Her )], 2 => [qw( fie fii foo fum )], 3 => [qw( aaa bbb ccc ddd )], ); my %hash2 = ( 1 => 3, 51 => 0, 32 => 1, ); foreach (sort keys %hash1){ local( $,, $\) = ("\t", "\n"); print @{ $hash1{$_} }, exists $hash2{$_} ? $hash2{$_} : q(); } OUTPUT: You Me Him Her 3 fie fii foo fum aaa bbb ccc ddd
Bill
  • Comment on Re: looping through a hash and looking up values from another hash
  • Download Code