Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my %hash = map {($part1[$_] => [$part2[$_], $gp_ids[$_]])}0..$#part1; #print "$#island_ids $#nonisland_ids $#plasmid_ids\n"; my %map; @map{@island_ids} = ("island") x @island_ids; @map{@nonisland_ids} = ("nonisland") x @nonisland_ids; @map{@plasmid_ids} = ("plasmid") x @plasmid_ids; while (my($k,$v) = each %hash) { print "$map{$k}-$map{$v->[0]} $map{$v->[1]}\n"; } use Data::Dumper; print Dumper \%hash; # output from hash: island-plasmid plasmid-island plasmid-island island-nonisland plasmid-island # output from Dumper: 'c6679893-6679264 ' => [ '39687-39872 ', '1' ], 'c4702714-4702079 ' => [ 'c78072-77437 ', '138' ],
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hashes with multiple values per key
by puudeli (Pilgrim) on Apr 04, 2006 at 10:27 UTC | |
|
Re: hashes with multiple values per key
by lima1 (Curate) on Apr 04, 2006 at 09:57 UTC | |
by Anonymous Monk on Apr 04, 2006 at 10:02 UTC | |
by lima1 (Curate) on Apr 04, 2006 at 10:20 UTC | |
by Anonymous Monk on Apr 04, 2006 at 10:23 UTC | |
by lima1 (Curate) on Apr 04, 2006 at 10:34 UTC | |
|