in reply to Case insensitivity in a hash... Futile effort?
Here's a sample program using it:package Tie::RecursiveCI; use strict; use Tie::CaseInsensitive; use vars qw( @ISA ); @ISA = qw( Tie::CaseInsensitive ); sub STORE { my ($self, $key, $value) = @_; $self->{lc $key} = $value; if (UNIVERSAL::isa($value,'HASH')) { tie %{ $self->{lc $key} }, 'Tie::RecursiveCI'; } return $self->{lc $key}; }
And here's the output:#!/usr/bin/perl use Tie::RecursiveCI; tie %hash, 'Tie::RecursiveCI'; $hash{foo} = 10; $hash{Foo} = 20; $hash{bar}{blat} = 30; $hash{BAR}{blAT} = 40; for (sort keys %hash) { print "$_ => $hash{$_}\n"; } for (sort keys %{ $hash{bAr} }) { print "$_ => $hash{bar}{$_}\n"; }
bar => HASH(0xd67b0) foo => 20 blat => 40
|
|---|