in reply to Re: Case insensitivity in a hash... Futile effort?
in thread Case insensitivity in a hash... Futile effort?

So to tie a hash four dimensional hash, I would:
$level1 = "LEVEL1"; $level2 = "LEVEL2"; $level3 = "LEVEL3"; $setting1 = "level1"; $setting2 = "level2"; $setting3 = "level3"; use Tie::CaseInsensitive; tie %{$HASH{$level1}{$level2}{level3}}, 'Tie::CaseInsensitive'; $HASH{$level1}{$level2}{level3} = 3; $HASH{$setting1}{$setting2}{setting3} = "Three"; use Data::Dumper; print Dumper \%HASH;
I tried to run this code and got the following error:
Can't locate Tie/CaseInsensitive.pm in @INC at ./hashTieTest.pl line 12.
I'm guessing this means that I need to add a .pm .
but which one? Is there a tie.pm? I'll go check CPAN. -Chuck

Replies are listed 'Best First'.
RE: RE: Re: Case insensitivity in a hash... Futile effort?
by btrott (Parson) on Apr 19, 2000 at 03:02 UTC
    Tie::CaseInsensitive can be gotten here: Re: case sensitivity in hashes.

    Just copy and paste it into your editor, save it, then put it somewhere in your @INC as Tie/CaseInsensitive.pm.

    And w/ a multi-dimensional hash, you need to tie each level of the hash. Does that make sense? So you tie the hash %HASH, then you tie $HASH{level1}, and so on down.

      I hate sounding ignorant, but once I know what I'm doing I promise to answer questions rather than just ask them.

      How do I add something to @INC. All my books are at work and I'm trying to get this done.

      Your humble servant,
      -Chuck
        There are several ways. But here's the easiest:
        use lib '/foo/bar';
        Adds the path '/foo/bar' to your @INC so it'll be searched. So, for your purposes, if you had installed Tie::CaseInsensitive (or Tie::RecursiveCI, japhy's code, which you should use because then you don't have to retie each level) in '/home/foo/bar/Tie/RecursiveCI.pm', you'd put
        use lib '/home/foo/bar';
        at the top of your code.
      Thanks a lot, It makes sense, but I don't think I'd have figured it out :-)
      -Chuck