in reply to Multiple keys for a hash table row?

Hello mike6535,
In the end I'd like to have several alternative "keys" per row, including some subset of abbreviations.
The behaviour you described is exactly what GetOpt::Long does with arguments. Take a loong breath and dive in it's source code to see how a real world wheel works.

Yes! you can reinvent the wheel (but see my signature..). In this case you can profit of the core module Text::Abbrev to have all unique abbreviations from a list, but you need to check for duplicates and collisions...

Probably have a dedicated sub to get the job done. Let's assume we want that the keys are in different languages and that values are just strings of words like in your example; something like (semitested!):
use strict; use warnings; my %multikeys; my %yet_used; # alternatives # value multikeyize ('colors|colores|farben|col|c',"red green purple"); multikeyize ('animals|animalia|a',"sheep cow dog"); # warning example: redefining a masterkey # multikeyize ('colors|xss|x',"tizio caio sempronio"); # warning example: redefining an alias # multikeyize ('c|xss|x',"tizio caio sempronio"); sub multikeyize{ my $alternatives= shift; my $value = shift; my @alternate = split /\|/,$alternatives; my $masterkey = shift @alternate; # masterkeys take the precedence.. if ($yet_used{$masterkey}){ print "\tWARNING '$masterkey' already defined! wiping previous + value!", ( $yet_used{$masterkey}=~/^1$/ ? "(was an alias)" : "(was a masterkey with value of '$yet_used{$masterkey} +')" ),"\n"; undef $yet_used{$masterkey}; } $multikeys{$masterkey} = $yet_used{$masterkey} = $value; map { $yet_used{$_}++; $multikeys{$_} = \$multikeys{$masterkey}; # just to show it.. print "$_->"; } grep {not exists $yet_used{$_} } @alternate; # just to show it.. print "(masterkey) $masterkey = '$multikeys{$masterkey}'\n\n"; } __OUTPUT__ colores->farben->col->c->(masterkey) colors = 'red green purple' animalia->a->(masterkey) animals = 'sheep cow dog'


HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.