in reply to how to use the values of the first hash to be the keys for the second hash
Update: Or, you can use map:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash1 = (key1 => [qw(val1 val2)], key2 => ['val3'], ); my %hash2 = (val1 => [qw(val5 val6 val7)], val2 => [qw(val8 val9)], val3 => ['val3'], ); print Dumper { map { $_ => [ map @{ $hash2{$_} } , @{ $hash1{$_} } ] } keys %hash1 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to use the values of the first hash to be the keys for the second hash
by lrl1997 (Novice) on Sep 07, 2012 at 18:09 UTC | |
by choroba (Cardinal) on Sep 07, 2012 at 18:24 UTC | |
by lrl1997 (Novice) on Sep 07, 2012 at 19:16 UTC | |
by choroba (Cardinal) on Sep 07, 2012 at 23:21 UTC | |
by lrl1997 (Novice) on Sep 07, 2012 at 18:12 UTC |