in reply to looping through a hash and looking up values from another hash
I would use exists rather than defined to check for the existence of a hash key, but either way, I get the same thing everyone else gets:
c:\@Work\Perl\monks>perl -wMstrict -le "my %hash1 = ( 1 => [ 'You', 'Me', 'Him', 'Her' ], 2 => [ 'You', 'Me', 'Him', 'Her' ], 3 => [ 'You', 'Me', 'Him', 'Her' ], ); my %hash2 = (1 => 3, 51 => 0, 32 => 1); ;; foreach my $k (keys %hash1) { if (exists $hash2{$k}) { print qq{@{ $hash1{$k} }, '$hash2{$k}'}; } } " You Me Him Her, '3'
Give a man a fish: <%-{-{-{-<
|
|---|