But then you'd lose the original case information. You'd have to have a hash of arrays to preserve the different case variations.
Update:
Here's a way to do it with a hash of hashes:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my @original_array = qw( THIS This That That ThAT ThAt ThAt THIS These
+ Those );
my %results;
map { $results{uc($_)}->{$_} = undef } @original_array;
print "Original\n", Dumper(@original_array), "\n";
print "Result\n", Dumper( %results ), "\n";
__END__
Original
$VAR1 = 'THIS';
$VAR2 = 'This';
$VAR3 = 'That';
$VAR4 = 'That';
$VAR5 = 'ThAT';
$VAR6 = 'ThAt';
$VAR7 = 'ThAt';
$VAR8 = 'THIS';
$VAR9 = 'These';
$VAR10 = 'Those';
Result
$VAR1 = 'THAT';
$VAR2 = {
'ThAT' => undef,
'ThAt' => undef,
'That' => undef
};
$VAR3 = 'THIS';
$VAR4 = {
'THIS' => undef,
'This' => undef
};
$VAR5 = 'THOSE';
$VAR6 = {
'Those' => undef
};
$VAR7 = 'THESE';
$VAR8 = {
'These' => undef
};
|