in reply to How to group keys by hash value
You might want to setup another hash to map your ids to their appropriate case groups. See. perldsc for more info on data structures in perl.use Data::Dumper; my %hash = ( ABC => 'foo', DEF => 'bar', XXX => 'baz', YYY => 'quux', ); my %casehash; for(keys %hash) { $casehash{CaseA}->{$_} = $hash{$_} if /^[A-F]+\z/; $casehash{CaseZ}->{$_} = $hash{$_} if /^[W-Z]+\z/; } print Dumper(\%casehash); __output__ $VAR1 = { 'CaseA' => { 'ABC' => 'foo', 'DEF' => 'bar' }, 'CaseZ' => { 'XXX' => 'baz', 'YYY' => 'quux' } };
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to group keys by hash value
by donno20 (Sexton) on Apr 25, 2003 at 11:49 UTC | |
by Anonymous Monk on Apr 26, 2003 at 02:35 UTC |