in reply to Case insensitivity in a hash... Futile effort?
In a thread a while back, vroom wrote a nice solution using tie: Re: case sensitivity in hashes.
You'll have to modify it a bit, because you want multi- dimensional hashes; so I think you'd probably just have to tie all of the hashes of hashes of hashes, etc. So, for example, say you're using vroom's Tie::CaseInsensitive:
You should get:use strict; my %HASH; use Tie::CaseInsensitive; tie %HASH, 'Tie::CaseInsensitive'; $HASH{BoB} = 1; $HASH{bob} = 2; $HASH{BOb} = 3; tie %{$HASH{bill}}, 'Tie::CaseInsensitive'; $HASH{bill}{jones} = 3; $HASH{BILL}{JONES} = 2; use Data::Dumper; print Dumper \%HASH;
which looks quite right.$VAR1 = { 'bill' => { 'jones' => 2 }, 'bob' => 3 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Case insensitivity in a hash... Futile effort?
by ChuckularOne (Prior) on Apr 19, 2000 at 00:37 UTC | |
by btrott (Parson) on Apr 19, 2000 at 03:02 UTC | |
by ChuckularOne (Prior) on Apr 19, 2000 at 05:27 UTC | |
by btrott (Parson) on Apr 19, 2000 at 07:06 UTC | |
by ChuckularOne (Prior) on Apr 19, 2000 at 04:19 UTC |