in reply to looping through a hash and looking up values from another hash
what is wrong with my loop?
You are missing the sigil and searching for a key with the hard-coded value of 'keys'.
if (defined $hash2{keys}){ ^
Try this:
for my $key ( sort keys %h1 ) { say sprintf("%s: %s\t%s", $key, "@{ $h1{ $key } }", $h2{ $key }) i +f defined $h2{ $key }; }
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: looping through a hash and looking up values from another hash
by pearllearner315 (Acolyte) on Apr 26, 2017 at 03:25 UTC | |
by huck (Prior) on Apr 26, 2017 at 03:31 UTC |